DEV Community

kim-jos
kim-jos

Posted on • Updated on

What is the JS Execution Context?

What is the execution context in JS?

Everything in JS happens within an execution context. Imagine a big box with two sides or look at the diagram below. The left side is the memory component(variable environment) while the right side is the code component(thread of execution).

image

What does the memory component of the execution context do?

The memory component(variable environment) is where all the variables and functions are stored in key value pairs even before code is executed.

What does the code component of the execution context do?

The code component(thread of execution) is where all JS code is executed one line at a time.

Is JS a synchronous single-threaded language?

Yes.

What does single-threaded mean?

Single-threaded means that JS can only execute one thing at a time.

What does synchronous mean?

Synchronous signifies the order in which JS executes code. JS can execute the next line of code only if the current line of code has been executed.

Top comments (0)