Introduction to Programming
Variables: The Tupperware of Programming
Scope of variables
You can create new variables with var. If you had a function named "Squiggly" and you used var to define the variable "Gobbledygook" within it, Gobbledygook would be a local variable, and would only be relevant inside Squiggly. Now, if you used var to define a variable called "Gibberish,", just by itself with no association to a function, it would be a global variable. It's not specific to one function but rather can be applied to any function at any time. An important thing to note is that global variables take precedence over local variables. So, if you call Gobbledygook within Squiggly, but there is also a global variable with the same name being applied to the function, the value of the global variable will be evaluated instead. Take a look here for details about this.
BreBru.com Information Technology HTML