This core language is also used in non-browser environments, for example in node.js.
What falls under the ECMAScript scope?
Among other things, ECMAScript defines:
- Language syntax (parsing rules, keywords, control flow, object literal initialization...)
- Error handling mechanisms (throw, try/catch, ability to create user-defined Error types)
- Types (boolean, number, string, function, object...)
- The global object. In a browser, this global object is the window object, but ECMAScript only defines the APIs not specific to browsers, e.g.
- A prototype-based inheritance mechanism
- Built-in objects and functions (
Array.prototypemethods, Object introspection methods...)
- Strict mode
As of August 2014, the current versions of the major Web browsers implement ECMAScript 5.1, but older versions (still in use) implement ECMAScript 3 and only parts of ECMAScript 5. Nowadays browsers already implement large parts of ECMAScript 6.
The proposed fourth edition of ECMA-262 (ECMAScript 4 or ES4) would have been the first major update to ECMAScript since the third edition published in 1999. As of August 2008, the ECMAScript 4th edition proposal has been scaled back into a project codenamed ECMAScript Harmony, that defines among others, things like Proxies or the
const keyword. Progress can be followed here. A major 6th Edition of the standard is expected to come out in 2015.
The WebIDL specification provides the glue between the DOM technologies and ECMAScript.
The Core of the DOM
The Document Object Model (DOM) is a cross-platform, language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Objects in the DOM tree may be addressed and manipulated by using methods on the objects. The W3C standarizes the Core Document Object Model, which defines language-agnostic interfaces that abstract HTML and XML documents as objects, and also defines mechanisms to manipulate this abstraction. Among the things defined by the DOM, we can find:
- The document structure, a tree model, and the DOM Event architecture in DOM core:
- A less rigorous definition of the DOM Event Architecture, as well as specific events in DOM events.
- Other things such as DOM Traversal and DOM Range.
From the ECMAScript point of view, objects defined in the DOM specification are called "host objects".
HTML, the Web's markup language, is specified in terms of the DOM. Layered above the abstract concepts defined in DOM Core, HTML also defines the meaning of elements. The HTML DOM includes such things as the
className property on HTML elements, or APIs such as
The HTML specification also defines restrictions on documents; for example, it requires all children of a
ul element, which represents an unordered list, to be
li elements, as those represent list items. In general, it also forbids using elements and attributes that aren't defined in a standard.
Other notable APIs
setIntervalfunctions were first specified on the
Windowinterface in HTML Standard.
- XMLHttpRequest makes it possible to send asynchronous HTTP requests.
- The CSS Object Model abstract CSS rules as objects.
- WebWorkers allows parallel computation.
- WebSockets allows low-level bidirectional communication.
- Canvas 2D Context is a drawing API for
As every web developer has experienced, the DOM is a mess. Browser support uniformity varies a lot from feature to feature, mainly because many important DOM features have very unclear, specifications (if any), and different web browsers add incompatible features for overlapping use cases (like the Internet Explorer event model). As of June 2011, the W3C and particularly the WHATWG are defining older features in detail to improve interoperability, and browsers in turn can improve their implementations based on these specifications.