Function scope (Definition)

The context within which the body script runs is the function scope.

JavaScript uses static scoping. This means that the functions are executed in the scope in which they are defined. This is important because any global values they refer to belong to the page in which they live. That is not necessarily the page that they were called from. This is only likely to cause any confusion when a multiple framed document is being rendered.

The function scope is the state of the scope chain as it was when the function was called, plus the call object added onto the end of the scope chain. The call object is the function being executed.

Because the call object is added to the scope chain, you don't need to refer to it explicitly and the current context inherits all its properties and methods.

Warnings:

See also:Event handler scope, RegExp object