- Hoisting means variable and function declarations are moved to the top of their scope before code execution.
Example:
console.log(a); // undefined
var a = 5;
var
is hoisted (declared but not initialized).- With
let
andconst
, hoisting happens too, but they remain in a temporal dead zone until declared.
Leave a Reply