The ECMAScript 5 specification contains the following description of its scope:
The fifth edition of ECMAScript (published as ECMA-262 5th edition)
- codifies de facto interpretations of the language specification that have become common among browser implementations and
adds support for new features that have emerged since the publication of the third edition. Such features include
- accessor properties,
- reflective creation and inspection of objects,
- program control of property attributes,
- additional array manipulation functions,
- support for the JSON object encoding format, and
- a strict mode that provides enhanced error checking and program security.
The new features included in ECMAScript 5 are as follows:
'use strict'
;
> var obj = { get foo() { return 'abc' } }; > obj.foo 'abc'
ECMAScript 5 includes the following syntactic changes:
You can use reserved words (such as new
and function
) after the dot operator and as unquoted property keys in object literals:
> var obj = { new: 'abc' }; > obj.new 'abc'
ECMAScript 5 brought several additions to JavaScript’s standard library. This section lists them by category.
Getting and setting prototypes (see Getting and Setting the Prototype):
Object.create()
Object.getPrototypeOf()
Managing property attributes via property descriptors (see Property Descriptors):
Object.defineProperty()
Object.defineProperties()
Object.create()
Object.getOwnPropertyDescriptor()
Listing properties (see Iteration and Detection of Properties):
Object.keys()
Object.getOwnPropertyNames()
Protecting objects (see Protecting Objects):
Object.preventExtensions()
Object.isExtensible()
Object.seal()
Object.isSealed()
Object.freeze()
Object.isFrozen()
New Function
method (see Function.prototype.bind(thisValue, arg1?, ..., argN?)):
Function.prototype.bind()
Strings (see Chapter 12):
String.prototype.trim()
[...]
New Array
methods (see Array Prototype Methods):
Array.isArray()
Array.prototype.every()
Array.prototype.filter()
Array.prototype.forEach()
Array.prototype.indexOf()
Array.prototype.lastIndexOf()
Array.prototype.map()
Array.prototype.reduce()
Array.prototype.some()
New Date
methods (see Date Prototype Methods):
Date.now()
Date.prototype.toISOString()
Support for JSON (see Chapter 22):
JSON.parse()
(see JSON.parse(text, reviver?))
JSON.stringify()
(see JSON.stringify(value, replacer?, space?))
Some built-in objects have special toJSON()
methods:
Boolean.prototype.toJSON()
Number.prototype.toJSON()
String.prototype.toJSON()
Date.prototype.toJSON()
The following resources will be useful if you need to work with legacy browsers: