[Contents] [Previous] [Next] [Index]

var

Declares a variable, optionally initializing it to a value.

Implemented in

Navigator 2.0, LiveWire 1.0

Syntax

var varname [= value] [..., varname [= value] ]

Arguments

varname
Variable name. It can be any legal identifier.

value
Initial value of the variable and can be any legal expression.

Description

The scope of a variable is the current function or, for variables declared outside a function, the current application.

Using var outside a function is optional; you can declare a variable by simply assigning it a value. However, it is good style to use var, and it is necessary in functions if a global variable of the same name exists.

Examples

var num_hits = 0, cust_no = 0


[Contents] [Previous] [Next] [Index]

Last Updated: 10/31/97 12:29:59


Copyright � 1997 Netscape Communications Corporation