JavaScript/Reserved words/var

From Wikibooks, open books for an open world
Jump to: navigation, search
Previous: typeof Reserved words Next: void

The var keyword[edit]

The var keyword is optional and used to declare a variable. This operator is necessary iff the code includes the line "use strict;".

Syntax[edit]

  var variable[, variable2, ];

Examples[edit]

  var number = 17;

  number += 2; // number is now 19

  var theArray = new Array();
Previous: typeof Reserved words Next: void