Main Page


ECMA-262 describes a set of
that ECMAScript supports. These keywords indicate beginnings
and/or endings of ECMAScript statements. By rule, keywords are reserved and cannot be used as vari-
able or function names. Here is the complete list of ECMAScript keywords:
break else new var
case finally return void
catch for switch while
continue function this with
default if throw
delete in try
do instanceof typeof
If you use a keyword as a variable or function name, you will probably be greeted with an error message
like this: “Identifier expected.”
Reserved Words
ECMAScript also defines a number of
reserved words
. The reserved words are, in a sense, words that are
reserved for future use as keywords. Because of this, reserved words cannot be used as variable or func-
tion names. The complete list of reserved words in ECMA-262 Edition 3 is as follows:
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
If you use a reserved word as a variable or function name, more than likely you
will not
receive an
error...until a future browser implements one of them. Then the word will be considered a keyword,
and you will get a keyword error.
Primitive and Reference Values
In ECMAScript, a variable can hold one of two types of values: primitive values and reference values.
Primitive values
are simple pieces of data that are stored on the
, which is to say that their
value is stored directly in the location that the variable accesses.
Reference values
, on the other hand, are objects that are stored in the
, meaning that the value
stored in the variable location is a
to a location in memory where the object is stored.
ECMAScript Basics
05_579088 ch02.qxd 3/28/05 11:35 AM Page 15

JavaScript EditorFree JavaScript Editor     Ajax Editor