DEV Community

Ashik Patel
Ashik Patel

Posted on

How JavaScript works ?

Hey, let's talk about how JS works.

To the very base level every single execution that happening in JavaScript is happening inside the 'Execution Context'. It is responsible for executing the code line by line with the available context. Before going further, consider the following illustration to get good idea of how execution context look like and works.

Image description

You can assume execution context as a container having 2 parts.

  1. Code also known as thread of execution
  2. Memory also known as variable environment.

Code is basically a place in execution context where generally our JS code resides. It will make the program line by line and so that is why JavaScript is called as single threaded language. In addition to this, JavaScript also executes the code in specific manner or way, it is called single threaded synchronous programming language as well.

Memory is responsible for storing variable, functions and etc. While executing the program, JS will consume these variables and functions from the memory. Most importantly all of these stored variable, functions and etc are being stored as a key value pair.

So this is how JS works basically.

Top comments (0)