Hoisting might sound a bit confusing but it’s really not, let’s see how.
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 :
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…