Hoisting in javascript

Hoisting in javascript is a special feature of moving all the declarations to the top. In javascript the variable can be declared after it has been used

x = 30;

var x;

Only the declarations has been hoisted not the initializations

Note : JavaScript in strict mode does not allow variables to be used if they are not declared.

By Pankaj Kumar Agarwal

Leave a reply:

Site Footer