+ 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?

30th Sep 2016, 2:43 PM
Sjoerd Flameling
Sjoerd Flameling - avatar
13 Answers
+ 3
I fixed it! the problem was that I put brackets after the function in "addEventListener()" and "removeEventListener()".
2nd Oct 2016, 4:00 PM
Sjoerd Flameling
Sjoerd Flameling - avatar
+ 2
how do I fix that
30th Sep 2016, 9:09 PM
Sjoerd Flameling
Sjoerd Flameling - avatar
+ 2
no, check on the code playground:
30th Sep 2016, 9:14 PM
Sjoerd Flameling
Sjoerd Flameling - avatar
+ 2
Advanced Calculator. All Functions. Still in progress.
30th Sep 2016, 9:14 PM
Sjoerd Flameling
Sjoerd Flameling - avatar
+ 1
I did that in my code
30th Sep 2016, 8:51 PM
Sjoerd Flameling
Sjoerd Flameling - avatar
+ 1
I probably forgot to type it in my question.
30th Sep 2016, 8:52 PM
Sjoerd Flameling
Sjoerd Flameling - avatar
+ 1
function clrScrn() { inp.ut.value = ""; var clr = document.getElementsByTagName("button"); clr.removeEventListener("click", clrScrn(), true); }
30th Sep 2016, 8:59 PM
Sjoerd Flameling
Sjoerd Flameling - avatar
+ 1
okay
30th Sep 2016, 9:09 PM
Sjoerd Flameling
Sjoerd Flameling - avatar
0
i guess you forgot to put "}" at end of for loop
30th Sep 2016, 7:34 PM
Danial Akbari
Danial Akbari - avatar
0
may i see clrScrun function decleration ?
30th Sep 2016, 8:58 PM
Danial Akbari
Danial Akbari - avatar
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(); }
30th Sep 2016, 9:07 PM
Danial Akbari
Danial Akbari - avatar
0
its all of your code?
30th Sep 2016, 9:11 PM
Danial Akbari
Danial Akbari - avatar
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
2nd Nov 2021, 7:24 AM
creigmalta