Sunday, December 21, 2014

Hoisting in JavaScript

Hoisting in JavaScript

Moving the declaration of variable and function at the top is called Hoisting.
First function declaration is hoisted and then variable declaration is hoisted.

Example 1

In the above program JavaScript compiler moves declaration of variable at the top.

Example 2

In the above program JavaScript compiler moves declaration of variable and function at the top.

No comments:

Post a Comment