3 ms·
Yes. V8 and other JS compilers optimize tail calls, but it's not guaranteed by the standard. (i think IE doesn't, for example)
by gcr 15y ago
Yes. V8 and other JS compilers optimize tail calls, but it's not guaranteed by the standard. (i think IE doesn't, for example)
- mhansen 15y agoI'm not sure where you got this idea. V8 does not optimize tail calls. It's easy to see this in the Chrome console, I just entered this now: var a = function(x) { if (x == 0) return 'done'; return a(x-1); }; a(100000); RangeError: Maximum call stack size exceeded http://code.google.com/p/v8/issues/detail?id=457 http://code.google.com/p/v8/issues/detail?id=457
- gcr 15y agoWait, seriously? I didn't know that. Thanks for the link! Guess it's time for me to stop relying on that behavior...