JavaScript & Advanced ES6+ (0-to-Hero Big Tech Standard) › 07. Execution Context Lifecycle: Creation Phase vs Execution Phase
45 mins
← Prev Next →
Course Syllabus
Interactive Lesson Studio
Loading lesson content...

🎯 Big Tech Coding & Interview Challenges

Practice these curated problems. Click "Load in Sandbox" to solve live in the Code Studio!

2 Questions
Easy

1. Call Stack Depth Measurement

Write a function `measureStackDepth()` that recursively calls itself to calculate the exact maximum call stack size of the current JavaScript runtime environment.

💡 View Pro Interview Hint
• Use a try-catch block to catch RangeError and return depth.
Hard

2. Trampoline Pattern (Preventing Stack Overflow in Recursion)

Large recursions cause stack overflow. Implement a generic `trampoline(fn)` combinator that converts recursive tail-calls into an iterative while-loop, allowing 1,000,000+ recursive steps without stack overflow.

trampoline(recursiveSum(1000000)) -> 500000500000 without crashing!
💡 View Pro Interview Hint
• Return a function (thunk) instead of invoking recursively.
JavaScript
Live Execution Terminal
Click "Execute Live" to run code.