I would like to use lambda expressions or anonymous methods in JS.
- Is it possible?
- If so, how?
Example code illustrating what I would want to achieve:
function Start()
{
yield WaitWhile( /* What goes here? */ );
// In C# I could have written:
// yield return WaitWhile( () => name == "wait" );
}
function WaitWhile(System.Func.<boolean> predicate)
{
while (predicate())
yield;
}
I know I can make use of named delegates, but that is not what I want to achieve here.