what is variable scope?

when you declare a variable outside the function, then it is called as a global variable. when you declare a variable with in a function, then it is called as a local variable.

JavaScript ECMA Script does not have block statements ( if , for , while) scope.

For Example:

if(true){

     var x = 15;

}

console.log(x); // x is 15

where as, In ECMA script let declaration was introduced.

if(true){

     let x = 15;

}

console.log(x); // x is not defined

No comments:

Post a Comment

Overview of AngularJS

AngularJS is an open source web application framework. It is now maintained by Google . The most of the code can be eliminated by using th...