The syntax of core language features is covered in this section. The data here is intended for use as a quick reference and examples will be kept to a minimum. For a more complete discussion of each item, see the appropriate chapter of the book. Our conventions will be
Italicized text to indicate a key term or phrase, and also to indicate a placeholder for some specified grammatical or lexical unit, such as an expression, statement, or sequence of characters.
Boldfaced text to indicate language keywords or reserved words.
[Bracketed text] to indicate optional grammatical units. Note that [unit1] [unit2] permits the absence of unit1 and unit2; or unit1 followed by unit2; or unit1; or unit2; while [unit1 [unit2]] permits the absence of unit1 and unit2; or unit1; or unit1 followed by unit2. The only exception is in the discussion of arrays and objects, which necessitate “real” brackets.
An ellipsis (...) to indicate repetition of the previous unit in the natural way.
Д to indicate a generic operator.
You can find the full specification for ECMAScript, which is the core of JavaScript, at www.ecma.ch, currently at http://www.ecma-international.org/publications/standards/Ecma-262.htm. Note, however, that there may be some slight aspects to the language discussed in this appendix that are part of the ad hoc standard implemented by browser vendors and not found in the ECMA specification.
The following points are core principles of JavaScript:
Excess white space is ignored when outside of a regular expression literal or string.
Statements are terminated with a semicolon.
Semicolons are automatically inserted on lines with complete statements. (Returns imply semicolons for complete statements.)
Data is weakly typed.
References to identifiers are resolved using lexical (static) scoping. The one exception to this is class properties of the RegExp object, which are dynamically scoped.
Indices are enumerated beginning with zero.
There are four kinds of available objects: built-in objects, host (browser) objects, document objects and user-defined objects.
It is a prototype-based object oriented language (not class-based in its current incarnation).
Source code is interpreted.
Comments use C++ inline comment style // or C-style block comment /* */.
I/O is limited in most cases to interaction with Web documents and the user (no local filesystem or network access by default).
The versions of the various core languages and their relationships are listed in Tables A-1 through A-6.
Standard Version |
Description |
---|---|
ECMAScript Edition 1 |
First standardized version of JavaScript, based loosely on JavaScript 1.0 and JScript 1.0. |
ECMAScript Edition 2 |
Standard version correcting errors within Edition 1 (and some very minor improvements). |
ECMAScript Edition 3 |
More advanced language standard based on ECMAScript Edition 2. Includes regular expressions and exception handling. In widespread use. |
ECMAScript Edition 4 |
New standard still unfinished at the time of this writing. |
Language Version |
Browser Version |
---|---|
JavaScript 1.0 |
Netscape 2 |
JavaScript 1.1 |
Netscape 3 |
JavaScript 1.2 |
Netscape 4.0–4.05 |
JavaScript 1.3 |
Netscape 4.06–4.7 |
JavaScript 1.4 |
None |
JavaScript 1.5 |
Netscape 6/7, Mozilla 1.0 |
JavaScript 2.0 |
Future versions of Mozilla-based browsers |
Language Version |
Browser Version |
---|---|
JScript 1.0 |
Internet Explorer 3.0 |
JScript 3.0 |
Internet Explorer 4.0 |
JScript 5.0 |
Internet Explorer 5.0 |
JScript 5.5 |
Internet Explorer 5.5 |
JScript 5.6 |
Internet Explorer 6.0 |
Language Version |
Browser Version |
Language Version |
Browser Version |
---|---|---|---|
JavaScript 1.0 |
Netscape 2.0 |
JScript 1.0 |
Internet Explorer 3.0 |
JavaScript 1.3 |
Netscape 4.06 |
JScript 3.0 |
Internet Explorer 4.0 |
JavaScript 1.5 |
Netscape 6/7, Mozilla |
JScript 5.5,5.6 |
Internet Explorer 5.5,6.0 |
Netscape Version |
Standard Version |
Exceptions |
---|---|---|
JavaScript 1.0–1.2 |
Very loose conformance to ECMA-262 Edition 1 |
Many, especially with the Date object, and many extra features |
JavaScript 1.3 |
Strict conformance to ECMA-262 Edition 1 |
Includes some extra features |
JavaScript 1.4 |
Strict conformance to ECMA-262 Edition 1 |
Includes some extra features |
JavaScript 1.5 |
Strict conformance to ECMA-262 Edition 3 |
Includes some extra features |
JavaScript 2.0 |
Planned conformance to ECMA-262 Edition 4 |
Unknown |
Microsoft Version |
Standard Version |
Exceptions |
---|---|---|
JScript 1.0 |
Very loose conformance to ECMA-262 Edition 1 |
Many, and some extra features |
JScript 3.0 |
Strict conformance to ECMA-262 Edition 1 |
Includes some extra features |
JScript 5.0 |
Strict conformance to ECMA-262 Edition 1 |
Includes many extra features |
JScript 5.5 |
Strict conformance to ECMA-262 Edition 3 |
Includes some extra features |
JScript 5.6 |
Strict conformance to ECMA-262 Edition 3 |
Includes some extra features |