Interview Hub
Sign in

Q1: What is hoisting in JavaScript?

EasyJavaScript 29

Answer

Hoisting is the compile-time behavior where var declarations and function declarations are assigned scope before execution, so they can be referenced earlier in the block/function without a ReferenceError (though var initializes as undefined until the line runs). let and const are hoisted too but stay in the temporal dead zone until their declaration line executes. Arrow functions assigned to const are not hoisted like function foo(){}.

EditorJavaScript · local only