Re:Bill Clementson's Blog: JavaScript and Lisp
by jdeseno on Friday December 11, 2009 @06:58PM
(#990827)
Nice but, anonymous recursion is possible with arguments.callee.
[ Parent
| on HN ]
Re:Bill Clementson's Blog: JavaScript and Lisp
by benatkin on Saturday December 12, 2009 @04:38AM
(#991375)
More on arguments.callee:
https://developer.mozilla.org/En/Core_JavaScript_1.5_Referen...
Re:Bill Clementson's Blog: JavaScript and Lisp
by vlisivka on Saturday December 12, 2009 @07:02AM
(#991435)
arguments.callee is deprecated in javascript 1.4. Use function name instead, so interpreter will have chance to perform tail recursion. Give names to your anonymous functions anyway: it will be much easier to trace them.
Example of anonymous recursive function with arguments.callee:
var factorial=function(n) {
return (!(n>1))? 1 : arguments.callee(n-1)*n;
}
Example of anonymous recursive function without arguments.callee: var factorial=function factorial(n) {
return (!(n>1))? 1 : factorial(n-1)*n;
}