February 1999 Draft
JavaScript 2.0
Compatibility
|
Thursday, February 18, 1999
Existing JavaScript 1.x scripts will continue to run in a browser environment because browsers will be able to distinguish JavaScript 2.0 or later scripts from JavaScript 1.x scripts and treat each script according to the language in which it was written. JavaScript 2.0 scripts can be distinguished as follows:
language
attribute of JavaScript2.0
.import
statement.Some developers will want to incrementally modify their JavaScript 1.x scripts to take advantage of JavaScript 2.0 features.
Many JavaScript 1.x scripts are compatible and will run unchanged in either JavaScript 1.x or JavaScript 2.0 (as long
as one changes the language
attribute or adds an import
statement). The vast majority of other JavaScript
1.x scripts can be made compatible via the following process, which can be performed automatically:
var
and function
declarations in a function into a scope that encloses
all of their references.traditional
and a newline before function
declarations that are used as constructors
or methods, or are called with fewer or more arguments than designated (JavaScript 1.x will treat traditional
as an expression and inser a phantom semicolon after it).void
expr by void(
expr)
.[
expr,
expr]
by expr[(
expr,
expr)]
because commas are now significant inside brackets.field
or eval
for identifiers (manual intervention may be needed if these are
used to name fields).We intend to provide a tool that will perform such transformations.
The main situations where manual intervention may be required are:
eval
.Object
and String
.
Waldemar Horwat Last modified Thursday, February 18, 1999 |