Statement JavaScript Tutorial

Syntax

var variable
    var variable = value
The var keyword is used to declare variables within a script.
If it is used in a function, the scope of the variable is confined to that function.
If used outside of a function, it can be accessed anywhere on the page.
The following example shows Using the var Keyword in Three Different Instances


    
      Examples of the var Keyword