Variable Hoisting in JavaScript

JavascriptWeb DevelopmentFront End Technology

When you can use a JavaScript variable before it is declared, it is done using a technique called hoisting. The parser read through the complete function before running it.

The behavior in which a variable appears to be used before it is declared is known as hoisting −

For example, the following,

points =200;
var points;

The above works the same like the following −

var points;
ponts = 200;


raja
Published on 16-Jan-2018 11:35:36

Advertisements