Skip to content

Latest commit

 

History

History
36 lines (17 loc) · 1.51 KB

cled7jr0r00000ajtbp6s1th2.md

File metadata and controls

36 lines (17 loc) · 1.51 KB

JavaScript Execution Context

Everything in JavaScript happens inside the Execution Context.

We can assume the execution context to be the big box🗃 container in which the whole JavaScript is executed.

So the execution context has 2 components in it.

  1. Memory Component

  2. Code Component

Memory Component / Variable Environment

  • It has a key: value pair to store the variable, and similarly, the functions are also stored here.

  • This memory component is also known as a variable environment.

Code Component / Thread of Execution

  • Here the code is executed one line at a time. also know the thread of execution.

  • The thread of execution is a thread is just thread where the code is executed one line at a time.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1676920395269/39d82294-44a2-411b-9d43-9c1d070f192e.png align="center")

JavaScript is a Synchronous Single threaded Language

The reason it's called a thread of execution is that it's like a single thread where the code is executed line by line.

When we say Synchronous Single threaded that means JavaScript can execute single command at a time and that too in a specific order.

This means it can go to the other line only when its previous line is executed, and JavaScript is not possible without this beautiful execution context at all.