
The JavaScript Language
|
3
break do if switch typeof
case else in this var
catch false instanceof throw void
continue finally new true while
default for null try with
delete function return
JavaScript also reserves the following words for possible
future extensions. You may not use any of these words as
identifiers either:
abstract enum int short
boolean export interface static
byte extends long super
char final native synchronized
class float package throws
const goto private transient
debugger implements protected volatile
double import public
In addition, you should avoid creating variables that have the
same name as global properties and methods: see the Glo-
bal, Object, and Window reference pages. Within functions,
do not use the identifier
arguments as an argument name or
local variable name.
Variables
Variables are declared and initialized with the var statement:
var i = 1+2+3;
var x = 3, message = 'hello world';
Variable declarations in top-level JavaScript code may be
omitted, but they are required to declare local variables
within the body of a function.
JavaScript variables are untyped: they can contain values of
any data type.
Global variables in JavaScript are implemented as properties
of a special Global object. Local variables within functions
are implemented as properties of the Argument object for