How does JavaScript work?

Harshit Adatra
1 min readMay 25, 2021

Execution context in JavaScript.

Everything inside the JS happens in the execution context. Imagine it as a sealed-off container inside the JS engine.

Execution context has two components-

  1. Code component- This is also known as Thread of Execution.The place where code is executed one line at a time.
  2. Memory component- Memory component is also known as variable environment. It is the place where all variables and functions are stores as ( key: value) pairs.

JS is synchronous single-threaded language

By single-threaded, we mean JS can only run 1 command at a time i.e execution happens only in a single thread.

By synchronous single-threaded, we mean it can run 1 command at a time, in a specific order. That is, it goes from one line of code to the next and then to the next. It can’t skip any, or jump to the previous one.

--

--