Why does the use of JavaScript arguments.callee result in a RangeError -


In the code given below, "Uncredited Range Array: Maximum Call Stack Exceeded", and I'm not sure why I think It will be a series of events:

The code runs on page load

A timeout callback is established

The call stack ends there

>

After 5 seconds, the function is called

The callout is reset again

and the call stack ends < / P>

etc.

< P> But I get the console output:

  xi = 0 uncheck range array: Maximum call stack size exceeded  

:

  & lt; Script & gt; Var xi = 0; (Function () {window.console & amp; console.log ("xi =" + xi ++); settimeout (function () {arguments.callee ();}, 5000);}) (); & Lt; / Script & gt;  

Thanks for any help.

The easiest task (anonymous function) is calling itself

  is setTimeout (function F () {f ();}, 5000);  

So this is the result of endless repetition.

What do you want:

  var xi = 0; (Function () {window.console & amp; console.log ("xi =" + xi ++); var f = arguments.callee; setTimeout (function () {f ();}, 5000);});  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -