function f (i, t) { if(t == 10000) { setTimeout(function () { console.log(i) f(i, 0) }, 0); } else if(i) f(i-1, t+1); } var a = 100000; f(a, 0)