what is execution context in javascript

everything in JS happens in the execution context

Chinmay
1 min readSep 22, 2022

js is,
— synchronous
— single-threaded

execution context (EC)

→ the ‘environment’ in which a function executes in
→ everything in JS happens in the execution context

→ every time a function is invoked a new execution context is pushed into the call stack

2 parts of EC ->
1.
memory component (a.k.a variable environment)
— where all functions and variables are stored as key-value pairs

2. code component (a.k.a thread of execution)
— component in which code executes one line at a time

the execution context

call stack (CS)

maintains the order of execution of the execution contexts
→ a.k.a execution stack/ program stack/ control stack/ runtime stack/ machine stack.

call stack

if you liked this article or found it useful, a follow would be much appreciated. Alternatively, you could buy me a coffee! All the support is much appreciated. :-)

https://www.linkedin.com/in/chinmay-kude

code execution beautifully explained in js

JavaScript Daily JavaScripting.com

Sign up to discover human stories that deepen your understanding of the world.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Chinmay
Chinmay

Written by Chinmay

I often describe myself as a software professional having the mindset to break things but the toolset to create and restore.

No responses yet

Write a response