Skip to content

Commit a49ab59

Browse files
committed
fix: improve technical accuracy in call stack concept page
- Update MDN links for execution contexts to point to correct documentation - Clarify distinction between execution context and stack frame terminology - Standardize terminology from 'Callback Queue' to 'Task Queue' - Add note about Firefox's non-standard InternalError for stack overflow
1 parent 2249c84 commit a49ab59

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

docs/concepts/call-stack.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ JavaScript is **[single-threaded](https://developer.mozilla.org/en-US/docs/Gloss
100100
3. **Keep track of local variables** — Each function has its own variables that shouldn't interfere with others
101101

102102
<Info>
103-
**ECMAScript Specification**: According to the official JavaScript specification, the call stack is implemented through "[execution contexts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#description)." Each function call creates a new execution context that gets pushed onto the stack.
103+
**ECMAScript Specification**: According to the official JavaScript specification, the call stack is implemented through "[execution contexts](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Execution_model#stack_and_execution_contexts)." Each function call creates a new execution context that gets pushed onto the stack.
104104
</Info>
105105

106106
---
@@ -219,7 +219,7 @@ console.log("Done!");
219219

220220
## Execution Context: What's Actually on the Stack?
221221

222-
When we say a function is "on the stack," what does that actually mean? Each entry on the call stack is called an **[execution context](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this#description)** (or **stack frame**). It contains everything JavaScript needs to execute that function.
222+
When we say a function is "on the stack," what does that actually mean? Each entry on the call stack is called an **[execution context](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Execution_model#stack_and_execution_contexts)**, sometimes referred to as a **stack frame** in general computer science terms. It contains everything JavaScript needs to execute that function.
223223

224224
<AccordionGroup>
225225
<Accordion title="Function Arguments">
@@ -476,9 +476,13 @@ Stack: [ empty ]
476476
| Browser | Error Message |
477477
|---------|---------------|
478478
| Chrome | `RangeError: Maximum call stack size exceeded` |
479-
| Firefox | `InternalError: too much recursion` |
479+
| Firefox | `InternalError: too much recursion` (non-standard) |
480480
| Safari | `RangeError: Maximum call stack size exceeded` |
481481

482+
<Note>
483+
Firefox uses `InternalError` which is a non-standard error type specific to the SpiderMonkey engine. Chrome and Safari use the standard `RangeError`.
484+
</Note>
485+
482486
### Common Causes of Stack Overflow
483487

484488
<AccordionGroup>
@@ -619,7 +623,7 @@ You might be wondering: "If JavaScript can only do one thing at a time, how does
619623
Great question! The call stack is only **part** of the picture.
620624

621625
<Note>
622-
When you use asynchronous functions like [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout), [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), or event listeners, JavaScript doesn't put them on the call stack immediately. Instead, they go through a different system involving the **[Event Loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Event_loop)** and **Callback Queue**.
626+
When you use asynchronous functions like [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout), [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), or event listeners, JavaScript doesn't put them on the call stack immediately. Instead, they go through a different system involving the **[Event Loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Event_loop)** and **Task Queue**.
623627

624628
This is covered in detail in the [Event Loop](/concepts/event-loop) section.
625629
</Note>

0 commit comments

Comments
 (0)