Function Literals

Although function literals create unnamed functions, the syntax allows a function name to be optionally
specified, which is useful when writing recursive functions that call themselves. For example:

var f = function fact(x) { if (x <= 1) return 1; else return x*fact(x-1); };

 

This line of code defines an unnamed function and stores a reference to it in the variable f . It does not
store a reference to the function into a variable named fact , but it does allow the body of the function to
refer to itself using that name. Note, however, that this type of named function literal was not properly
implemented before JavaScript 1.5.

你可能感兴趣的:(JavaScript,F#)