Skip to content

Commit

Permalink
feat: styling and self-ref links removal (#33408)
Browse files Browse the repository at this point in the history
* fix: removal self-ref

* feat: better call-stack-list styles

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* lint

* replace gfm callouts with codeblocks

* Apply suggestions from code review

Co-authored-by: Brian Thomas Smith <[email protected]>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Brian Thomas Smith <[email protected]>
  • Loading branch information
3 people committed May 7, 2024
1 parent 79d97ef commit 247b78b
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions files/en-us/glossary/call_stack/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,38 @@ greeting();
// [3] Some code here
```

The code above would be executed like this:
The call stack will be empty at the very beginning, and the code above would be executed like this:

1. Ignore all functions, until it reaches the `greeting()` function invocation.
2. Add the `greeting()` function to the call stack list.
2. Add the `greeting()` function to the call stack list, and we have:

> **Note:** Call stack list:
> \- greeting
```plain
- greeting
```

3. Execute all lines of code inside the `greeting()` function.
4. Get to the `sayHi()` function invocation.
5. Add the `sayHi()` function to the call stack list.
5. Add the `sayHi()` function to the call stack list, like:

> **Note:** Call stack list:
> \- sayHi
> \- greeting
```plain
- sayHi
- greeting
```

6. Execute all lines of code inside the `sayHi()` function, until reaches its end.
7. Return execution to the line that invoked `sayHi()` and continue executing the rest of the `greeting()` function.
8. Delete the `sayHi()` function from our call stack list.
8. Delete the `sayHi()` function from our call stack list. Now the call stack looks like:

> **Note:** Call stack list:
> \- greeting
```plain
- greeting
```

9. When everything inside the `greeting()` function has been executed, return to its invoking line to continue executing the rest of the JS code.
10. Delete the `greeting()` function from the call stack list.

> **Note:** Call stack list:
> EMPTY
10. Delete the `greeting()` function from the call stack list. Once again, the call stack become empty.

In summary, then, we start with an empty Call Stack. Whenever we invoke a function, it is automatically added to the Call Stack. Once the function has executed all of its code, it is automatically removed from the Call Stack. Ultimately, the Stack is empty again.

## See also

- [Call stack](https://en.wikipedia.org/wiki/Call_stack) on Wikipedia
- [Glossary](/en-US/docs/Glossary)

- {{Glossary("Call stack")}}
- {{Glossary("Function")}}
- {{Glossary("Function")}}

0 comments on commit 247b78b

Please sign in to comment.