2.8. Reserved WordsThere are a number of reserved words in JavaScript. These are words that you cannot use as identifiers (variable names, function names, and loop labels) in your JavaScript programs. Table 2-1 lists the keywords standardized by ECMAScript v3. These words have special meaning to JavaScript -- they are part of the language syntax itself. Table 2-1. Reserved JavaScript keywords
Table 2-2 lists other reserved keywords. These words are not currently used in JavaScript, but they are reserved by ECMAScript v3 as possible future extensions to the language. Table 2-2. Words reserved for ECMA extensions
In addition to some of the formally reserved words just listed, current drafts of the ECMAScript v4 standard are contemplating the use of the keywords as, is, namespace, and use. Current JavaScript interpreters will not prevent you from using these four words as identifiers, but you should avoid them anyway. You should also avoid using as identifiers the names of global variables and functions that are predefined by JavaScript. If you create variables or functions with these names, either you will get an error (if the property is read-only) or you will redefine the existing variable or function -- something you should not do unless you know exactly what you're doing. Table 2-3 lists global variables and functions defined by the ECMAScript v3 standard. Specific implementations may define other global properties, and each specific JavaScript embedding (client-side, server-side, etc.) will have its own extensive list of global properties.[4]
Table 2-3. Other identifiers to avoid
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|