var Keyword

Syntax

var varname1 [= value1] [, varname2 [= value2] ... [, varnameN [= valueN]]];

varnameN

Variable name. It can be any legal identifier.

valueN Optional

Initial value of the variable. It can be any legal expression. Default value is undefined.

Alternatively, the Destructuring Assignment syntax can also be used to declare variables.

var { bar } = foo; // where foo = { bar:10, baz:12 };
/* This creates a variable with the name 'bar', which has a value of 10 */