Monday, February 2, 2015

Everything You Need To Know About Javascript Variable Scope


Most of the people assume that scope of variable in Javascript is very much similar to other programming languages like Java and C. But there are a number of points where the behavior is different and very complex. Not only beginners, even few experienced Javascript programmers find it difficult to understand scope of variable in Javascript. These points are to be understood well to master Javascript and code with less syntactical as well as logical errors

The scope of a variable is the portion of the program code for which the variable's name has meaning and for which the variable is said to be "visible". Javascript has two types of scopes global and local(function) level scope. Variables declared globally that are visible throughout the javascript program come under global scope. Variables declared inside functions, may have same name as global varibles, are accessible only within that function are local variables.

Read This Article


No comments:

Post a Comment