javascriptfunctional-programmingtail-recursion

Are any JavaScript engines tail call (TCO) optimized?


I have a tail recursive pathfinding algorithm that I've implemented in JavaScript and would like to know if any (all?) browsers would possibly get stack overflow exceptions.


Solution

  • The ECMAScript 4 specification was originally going to add support for TCO, but it was dropped:

    No more tail calls in JavaScript?

    As of 2010, no widely-available implementations of JavaScript currently do automatic TCO.


    See comments for more recent updates.