Interview Question – Explain Hoisting in JavaScript

Hoisting is a default behavior of JavaScript where all the variable and function declarations are moved on top. This means that irrespective of where the variables and functions are declared, they are moved on top of the scope. The scope can be both local and global.

Below is the example: