This function should be tail call optimized.
To my knowledge, current browsers (Chrome, even tried it on Canary) should optimize it yet I get an error for this run:
function die(x, s) {
return x === 0 ? s : die(x-1, s+1);
}
die(100000, 0);
The error:
VM369:1 Uncaught RangeError: Maximum call stack size exceeded
Or did I get something wrong?