What is ECMAScript 2015 or ES6
Variables In ECMAScript:-
1.
Block
scope
2. Global scope
Global Scope:-
§ If we are declare any variable inside the file directly but outside of any function or block that variable comes in global scope i.e. variables have global scope.
//global scope § If any variable
have global scope that variable can be accessible anywhere in the program.
Function Scope:
Note:-
§ If any variable that have function scope that variable can be accessible only with-in function in which they are declared and that function can't be accessible outside the function.
var a=10
Note:-
§ If variable having same name in global scope and function scope then if we access that variable with in function then you will get function scope variable value but if you access outside variable then you will be get global scope variable value.
§ Variables that are declared by using var kwd can't have block scope.
§ Variables
declared inside a block {} can be access from outside the block.
Post a Comment