Algorithms and Data Structures · Senior · Question 65 of 75
Which statement about recursion and the call stack in JavaScript is correct?
- 1Recursion depth is unlimited in Node.js by default
- 2Every engine optimizes tail calls automatically
- ✓Correct answer: Tail calls are in the spec, but only Safari has them
Explanation
ES2015 specified proper tail calls in strict mode, but V8 and SpiderMonkey don't ship them. So in Chrome and Node.js a tail-recursive function still uses a frame per call and can overflow.