Global vs. Local Variables
-
Scope: where can the variable be used?
-
Global Variables can be used anywhere in the html document.
-
Local Variables can only be used in the function in which they were
declared.
-
This might be confusing now, but I guarantee this will be the cause of
a bug in software you write at some point...
-
Example: Global vs. Local
-
Lesson: use var for clarity. Comment, comment, comment!
assigning values
Home
Internet II: Day 2