4 ms·
JavaScript doesn't optimize tail recursion. I wrote about this, and how to use trampolines, a few years back: https://taylodl.wordpress.com/2013/06/07/functiona
by taylodl 9y ago
JavaScript doesn't optimize tail recursion. I wrote about this, and how to use trampolines, a few years back: https://taylodl.wordpress.com/2013/06/07/functional-javascript-tail-call-optimization-and-trampolines/ https://taylodl.wordpress.com/2013/06/07/functional-javascri...
- k__ 9y agoDoesn't JavaScript core optimize it?
- richdougherty 9y agoHere's the state of tail-call optimisation in JavaScript: https://kangax.github.io/compat-table/es6/#test-proper_tail_calls_(tail_call_optimisation) https://kangax.github.io/compat-table/es6/#test-proper_tail_... Discussion on this (apparently controversial!) feature: https://github.com/kangax/compat-table/issues/819 https://github.com/kangax/compat-table/issues/819
- k__ 9y agoYes, I know about the controverse. People say it blows up the stack traces, so it should be opt-in. But it seems that Node.js and Safari have it, and as far as I know Safari uses JavaScript Core, which is also used for React-Native.