Isn't it easier to turn it into a loop instead? :)

<untested>
You can just give it a name as so:
...
(function foo(k) {
  if (k++ < 11) call foo(k);
...

You will be unable to use foo() even from within the function that defined foo source: http://academ.hvcc.edu/~kantopet/old/javascript/index.php?page=adv+js+functions&parent=js+functions


another way (i think this might be deprecated)
"You can make recursive calls within an anonymous function using arguments.callee , which is a reference to the currently executing function (even if it has no name)."
source: http://www.dustindiaz.com/awkward-looking-javascript/
</untested>

<tip contents="Google is your friend" />

HTH
~KS


Eric H. Jung wrote:
Hi,

How can I recursively call an anonymous JS function? Something like:

var j = 1;
(function(k) {
  if (k++ < 11) call myself(k);
})(j);

Thanks for any ideas,
Eric


_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners

_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners

Reply via email to