Execution Context
Episode 1 : Execution Context
Section titled “Episode 1 : Execution Context”- Everything in JS happens inside the execution context. Imagine a sealed-off container inside which JS runs. It is an abstract concept that hold info about the env. within the current code is being executed.
flowchart TB subgraph EC["Execution Context"] direction TB Memory["💾 Memory Component(Variable Environment)
Variables stored askey-value pairs
var n = undefinedfunction square = {code}var square2 = undefined"] Code["⚡ Code Component(Thread of Execution)
Code executedone line at a time
1. n = 22. square2 = square(n)3. ..."] end
Memory --> Code
style EC fill:#1e293b,color:#fff style Memory fill:#7c3aed,color:#fff style Code fill:#059669,color:#fff
-
In the container the first component is memory component and the 2nd one is code component
-
Memory component has all the variables and functions in key value pairs. It is also called Variable environment.
-
Code component is the place where code is executed one line at a time. It is also called the Thread of Execution.
-
JS is a synchronous, single-threaded language
- Synchronous:- One command at a time.
- Single-threaded:- In a specific synchronous order.
Watch Live On Youtube below:
