「3.10.3 スコープチェーン」

The Scope Chain

JavaScript is a lexically scoped language: the scope of a variable can be thought of as the set of source code lines for which the variable is defined. Global variables are defined throughout the program. Local variables are defined throughout the function in which they are declared. and also within any functions nested within that function.


If we think of local variables as properties of some kind of implementation-defined object, then there is another way to think about variable scope. Every chunk of JavaScript code (global code or functions) has a scope chain associated with it. This scope chain is a list or chain of objects that defined the variables that are "in scope" for that code.

トラックバック - http://mnemonic.g.hatena.ne.jp/paragramma/20130314