What is Execution Context In JavaScript?๐Ÿค”

What is Execution Context In JavaScript?๐Ÿค”

ยท

1 min read

Note: Everything in JavaScript happens inside an Execution Context.

In JavaScript whenever a piece of code is executed then an execution context is created. In simple terms, we can say that execution context is a place where all the code and functions are available.

It has Two Components:

  1. Memory Component
  2. Code Component

Memory Component:

Memory Component is also known as Variable Environment. When a piece of code is executed JavaScript engine creates a global Execution Context(this is the default execution context). In that context memory component is created along with a code component or we can say a memory heap is created for storing the Variables and Functions. In-memory heap all the variable and function stored as Key-Value Pair e.g. b:10

Code Component:

Code Component is also a thread of execution. Code component is the place where all the code is executed line by line. JavaScript is a synchronous single threaded language and that's why only a single line of code executed at a time in sequence order.

Note: Global execution context is the default execution context of JavaScript.

Note: Everything in JavaScript happens inside an Execution Context**

ย