3 ms·
In my humble opinion, a for loop is easier to reason about then recursion. So one of JavaScript's "features" is that it does not have proper recursion support,
by z3t4 2y ago
In my humble opinion, a for loop is easier to reason about then recursion. So one of JavaScript's "features" is that it does not have proper recursion support, so you need to break out the recursion into a for loop, or the call stack will eventually become too big.
- williamdclt 2y agoWhat do you call "proper recursion support"? I assume it's tail-call optimisation, but I don't think it's a property of Javascript-the-language, but rather a property of the interpreter/compiler? I don't think there's anything inherent to javascript that would prevent V8 to have TCO (and I think it did use to have it) for example. And in fact I _think_ some engines do have TCO (bun? javascriptcore?), but I could be wrong
- Jtsummers 2y agoES6 added this: https://262.ecma-international.org/6.0/#sec-tail-position-calls https://262.ecma-international.org/6.0/#sec-tail-position-ca... So TCO is part of the language standard but not universally implemented. You are correct about the ones that support it.