What is hoisting?
Hoisting is JavaScript’s behavior of moving variable and function declarations to the
top of their scope during compilation.
Example:
console.log(a); // undefined
var a = 5;
Here, var a is hoisted but not initialized.
Hoisting is JavaScript’s behavior of moving variable and function declarations to the
top of their scope during compilation.
Example:
console.log(a); // undefined
var a = 5;
Here, var a is hoisted but not initialized.