+ 2
Uncaught RangeError maximum call stack size exceeded. Fixed
var clr = document.getElementsByTagName("button"); //clr.length equals 21 for(x = 0; x < clr.length; x++) { if (x == 5) {continue;} clr[x].addEventListener("click", clrScrn(), true); } it says: maximum call stack size exceeded. What does it mean? And how do I fix this?
13 Respostas
+ 3
I fixed it! the problem was that I put brackets after the function in "addEventListener()" and "removeEventListener()".
+ 2
how do I fix that
+ 2
no, check on the code playground:
+ 2
Advanced Calculator. All Functions. Still in progress.
+ 1
I did that in my code
+ 1
I probably forgot to type it in my question.
+ 1
function clrScrn() {
inp.ut.value = "";
var clr = document.getElementsByTagName("button");
clr.removeEventListener("click", clrScrn(), true);
}
+ 1
okay
0
i guess you forgot to put "}" at end of for loop
0
may i see clrScrun function decleration ?
0
the problem is that somewhere in your code you call a function which that function calls another function and goes forth until you reach call stack limit something like this:
function a() {
a();
}
0
its all of your code?
0
This error is almost always means you have a problem with recursion in JavaScript code, as there isn't any other way in JavaScript to consume lots of stack. Sometimes calling a recursive function over and over again, causes the browser to send you Maximum call stack size exceeded error message as the memory that can be allocated for your use is not unlimited.
How to fix
Wrap your recursive function call into a -
setTimeout
setImmediate or
process.nextTick
Also, you can localize the issue by setting a breakpoint on RangeError type of exception , and then adjust the code appropriately. Moreover, you can managed to find the point that was causing the error by check the error details in the Chrome dev toolbar console , this will give you the functions in the call stack, and guide you towards the recursion that's causing the error.
http://net-informations.com/js/err/range.htm