2
It’s a question that has more to do with curiosity, to understand how it works.
I know that if I call a function within it itself indefinitely I get the error Uncaught RangeError: Maximum call stack size exceeded
.
Initially, I thought there was a programmed limit of how many times the function would be called, and then I did the following snippet to test how many times the function runs before causing the error:
i = 0
function a() {
i++;
try{
return a()
} catch(e) {
console.log(i);
i = 0;
}
}
So far, so good.
But when executing a();
multiple times, it prints me different numbers at each run. And one thing I noticed is that, run a();
Several times quickly, increases the number of attempts before the error (from 20968 to 35945).
I tested on another machine, and the amount of attempts was different too.
So the question follows: How is the number of times executed before the error is set?
Cool question, let’s see what the experts say kk
– Richard Willian