Earn Money with study Materials - Click Here To Know More

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is Javascript Variable Hoisting
#1
Wink 
What is Javascript Variable Hoisting :


* Variable Hoisting is nothing but whenever declare a variable using var keyword. no matter what the declared variable is access from top of the scope.
* if you declare a variable on globally using var keyword it will be available for all the scopes.

Example 1:

Code:
console.log(age); // it will show undefined. because variable got hoisted on top of the scope
var age;
age = 10;

function a() {
console.log(age); // it will show 10. because variable got hoisted on top of the scope
}
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)