Hoisting might sound a bit confusing but it’s really not, let’s see how.

Image for post
Image for post

What is Hoisting ?

Hoisting is a JavaScript mechanism where variables and function declarations are available before the execution starts, regardless of whether their scope is global or local. In other words, functions and variables are hoisted in JavaScript.

Let’s see how hoisting works for variables and function declarations below :

Hoisting for Function Declarations

Before the execution starts, all the function declarations are present in the memory object. A property is created in the memory object, which points to the functions.

In the below snippet, as we all know, in…


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