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;


Updated on: 13-Jun-2020

167 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements