Are any JavaScript engines tail call (TCO) optimized?

后端 未结 6 1321
有刺的猬
有刺的猬 2020-11-27 03:02

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

6条回答
  •  时光取名叫无心
    2020-11-27 03:54

    Pretty much every browser you encounter will barf on "too much recursion". Here's an entry in the V8 bug tracker that will probably be interesting reading.

    If it's simple self-recursion, it's probably worth the effort to use explicit iteration rather than hoping for tail-call elimination.

提交回复
热议问题