Junior JavaScript

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.

More from JavaScript Tutorial

All questions for this course