I realise this is not the ideal place to ask about this in terms of searchability, but I\'ve got a page whose JavaScript code throws \"Stack overflow in line 0\" errors when
In my case I had two functions a()
and b()
. First was calling second and second was calling first one:
var i = 0;
function a() { b(); }
function b() {
i++;
if (i < 30) {
a();
}
}
a();
I resolved this using setTimeout
:
var i = 0;
function a() { b(); }
function b() {
i++;
if (i < 30) {
setTimeout( function() {
a();
}, 0);
}
}
a();