Hoisting is a phenomenon in javascript by which you can access variables and functions even before you initialize them. You can access it without any error.

In the below diagram, you can find that you can call getMe() and variable d before initializing it.

How does Javascript work and what is the Execution context?

Everything inside javascript happens inside the Execution context. The execution context has two parts (i)memory component (also known as Variable environment ) and (ii)code component (also known as Thread of execution).

The memory component stores a key-value pair. For example Key: a Value:10.

In the code component, code is executed…

Akshaya Gupta

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store