3.4. Scoping Variables
A variable's scope is the context of code where that variable can be accessed. Whenever a variable is defined, it is assigned a scope for access based on where it is in the code. It is available to all inner scopes; loops, function calls, and further nested control structures. Basically, it is available from the point it is first defined until the scope in which it was defined exits.
A variable is never available at a higher scope. If you declare a variable for use within function MyFunction(), for example, that variable and its value are not available to the caller but are available to any functions that MyFunction() calls. In fact, the variable is available to any functions called by functions that MyFunction() calls. This means there is no concept of local variables that are not visible outside your function (only those you call, and the functions they call, can see them).