DSGN53871
WEB DESIGN 1

Javascript Part Two

Local versus Global Variables

Local variables: A variable declared and accessed within a function.

When you exit the function, the variable is destroyed.

You can have local variables with the same name in several different functions with different values, because each iteration of the variable is recognized only by the function in which it is declared.

Global variables: A variable declared outside a function, which can be accessed from anywhere within a web page.

A global variable exists as long as it is declared and ends when the web page is closed.



<< Back


Interactive Multimedia ~ School of Applied Engineering and Computing Sciences ~ Sheridan