Variable Hoisting in JavaScript

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;