What error does JavaScript throw for stack overflow?
RangeError: Maximum call stack size exceeded. It is thrown when the call stack hits the engine's allocated limit.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Stack Overflow in JavaScript: Causes and Fixes
Unbounded or very deep recursion. Each call adds a frame to the call stack without popping one, until the engine's maximum stack size is exceeded and a RangeError is thrown.
Always include a base case that stops the recursion. For deep recursion that cannot be bounded, convert to an iterative loop or use a trampoline to run recursive steps without growing the stack.
It varies by engine and environment, typically 10,000-20,000 frames in browsers and Node.js. Do not write code that depends on a specific limit.
Still have questions?
Browse all our FAQs or reach out to our support team
