CopyPastor

Detecting plagiarism made easy.

Score: 0.8091579230533819; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-09-09
by Victoria Stampfli

Original Post

Original - Posted on 2011-05-23
by alex



            
Present in both answers; Present only in the new answer; Present only in the old answer;

It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you hit the call stack limit.
This is almost always because of a recursive function with a base case that isn't being met.
The following link has an example of how to set a timeout to avoid this error: https://www.hhutzler.de/blog/avoid-maximum-call-stack-size-exceeded-in-javascript/
It means that somewhere in your code, you are calling a function which in turn calls another function and so forth, until you hit the call stack limit.
This is almost always because of a recursive function with a base case that isn't being met.
###Viewing the stack
Consider this code...
(function a() { a(); })();
Here is the stack after a handful of calls...
![Web Inspector][2]
As you can see, the call stack grows until it hits a limit: the browser hardcoded stack size or memory exhaustion.
In order to fix it, ensure that your recursive function has a base case which is able to be met...
(function a(x) { // The following condition // is the base case. if ( ! x) { return; } a(--x); })(10);
[1]: http://stackoverflow.com/questions/310974/what-is-tail-call-optimization [2]: http://i.stack.imgur.com/aSwnu.png

        
Present in both answers; Present only in the new answer; Present only in the old answer;