Tuesday, September 20, 2016

Javascript tail-call

Having a function call as the last thing to run in a recursive function allows the JavaScript runtime to realize it doesn’t need to hold on to the current stack frame any longer, because it doesn’t have any more work to do; so it discards the stack frame. (only ES6 has this optimization)

this is the tail-call

No comments:

Post a Comment