JavaScript Hoisting
JavaScript Hoisting means that process whereby the interpreter appears to move the declaration of function, variables or classes to the top of their scope, prior to execution of the code.
Hoisting allows functions to be safely used in code before they are declared.
Example 1 – Write a Program to function hoisting in JavaScript:
Output
Example 2 – Write a Program to variable hoisting in JavaScript:
Output -