JavaScript: The Definitive Guide

Previous Chapter 2
Lexical Structure
Next
 

2.7 Reserved Words

There are a number of "reserved words" in JavaScript. These are words that you cannot (or should not) use as identifiers (such as variable names) in your JavaScript programs. Table 2.2 lists the keywords in JavaScript. These words have special meaning to JavaScript--they are part of the language syntax itself. This means that they should not be used as identifiers. Table 2.3 lists keywords from Java. Although JavaScript does not currently use any of these keywords, it might in future versions; you should avoid using them in your programs. Finally, Table 2.4 lists other identifiers to avoid. While these identifiers are not strictly reserved, they are the names of datatypes, functions, and variables that are predefined by client-side JavaScript; using them may cause unexpected behavior in your programs. Note that since Internet Explorer is not case-sensitive, you should avoid all variations of these identifiers in Table 2.4, whether in lower- or uppercase.

Table 2.2: Reserved JavaScript Keywords
break false in this void
continue for new true while
delete function null typeof with
else if return var

Table 2.3: Java Keywords Reserved by JavaScript
abstract default implements private throw
boolean do import protected throws
byte double instanceof public transient
case extends int short try
catch final interface static
char finally long super
class float native switch
const goto package synchronized

Table 2.4: Other Identifiers to Avoid
alert escape JavaPackage onunload setTimeout
Anchor eval length open status
Area FileUpload Link opener String
Array focus Location Option Submit
assign Form location Packages sun
blur Frame Math parent taint
Boolean frames MimeType parseFloat Text
Button Function name parseInt Textarea
Checkbox getClass navigate Password top
clearTimeout Hidden Navigator Plugin toString
close History navigator prompt unescape
closed history netscape prototype untaint
confirm Image Number Radio valueOf
Date isNaN Object ref Window
defaultStatus java onblur Reset window
Document JavaArray onerror scroll
document JavaClass onfocus Select
Element JavaObject onload self


Previous Home Next
Identifiers Book Index Variables and Data Types

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
Hosted by uCoz