JavaScript – JavaScript Subsets and Extensions

Until now, this book has described the complete and official
JavaScript language, as standardized by ECMAScript 3 and ECMAScript 5.
This chapter instead describes subsets and supersets of JavaScript. The
subsets have been defined, for the most part, for security purposes: a
script written using only a secure language subset can be executed
safely even if it comes from an untrusted source such as an ad server.
JavaScript Subsets describes a few of these subsets.

The ECMAScript 3 standard was published in 1999 and a decade
elapsed before the standard was updated to ECMAScript 5 in 2009. Brendan
Eich, the creator of JavaScript, continued to evolve the language during
that decade (the ECMAScript specification explicitly allows language
extensions) and, with the Mozilla project, released JavaScript versions
1.5, 1.6, 1.7, 1.8, and 1.8.1 in Firefox 1.0, 1.5, 2, 3, and 3.5. Some
of the features of these extensions to JavaScript have been codified in
ECMAScript 5, but many remain nonstandard. Future versions of ECMAScript
are expected to standardize at least some of the remaining nonstandard
features.

The Firefox browser supports these extensions, as does the
Spidermonkey JavaScript interpreter that Firefox is based on. Mozilla’s
Java-based JavaScript interpreter, Rhino, (see Scripting Java with Rhino)
also supports most of the extensions. Because these language extensions
are nonstandard, however, they will not be useful to web developers who
require language compatibility across all browsers. They are documented
in this chapter because:

  • they are quite powerful;

  • they may become standard in the future;

  • they can be used to write Firefox extensions;

  • they can be used in server-side JavaScript programming, when
    the underlying JavaScript engine is Spidermonkey or Rhino (see Scripting Java with Rhino).

After a preliminary section on language subsets, the rest of this
chapter describes these language extensions. Because they are
nonstandard, they are documented in tutorial style with less rigor than
the language features described elsewhere in the book.

Comments are closed.