DEV Community

Abdusanadzoda Abdulaziz
Abdusanadzoda Abdulaziz

Posted on

How JavaScript Works πŸ”₯& Execution Context

Do you know how JavaScript works and how the code is executed ?

Is JavaScript Synchronous or Asynchronous ?

Is JavaScript Single Threaded or Multy Threaded ?

If you are not familiriar with this so dont worry just keep reading.
So before going further just remember that "Everything in JavaScript happens inside an Execution Context!". You can asume this context as big box or a container in which whole JavaScript code is executed.

So lets divide this box or container in two parts left part will be Memory where all variables will be stored ad key valye pairs
ex: key:value;
And there is also another name for this Memory component which called Varibale Envirement.

The Second container is Code component , so this is the container where the code is executed line by line at the time.And people also call it Thread of Execution.

JavaScript Single Threaded or Multy Threaded

So when we say Single Threaded it means that JavaScript can only execute one line in a time.
And when we say Synchronous and Single Threaded that means that JavaScript can only execute one command in a time and in a specific order.Means that it can only go down if the current line has finished executing.

Top comments (0)