Planet For Application Life Development Presents
Technology World

Explore and uptodate your technology skills...

News Navigation: First Previous Next Last

Everything You Need To Know About Javascript Variable Scope
03-Feb-2015

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.