History of JavaScript: Part 7

2010-07-05 00:00:00 +0100 by Alex R. Young

This article is part 7 of our History of JavaScript series. Last week I
covered the history of JavaScript animation. This week I'll take a look
at ECMAScript 5.

JavaScript 2

If you recall part 3, JavaScript
2 died as the community fought over the direction of the language's
future. ECMA-262 5th edition was approved in
The original press release states:

Work on future ECMAScript editions continues as part of the previously announced ECMAScript Harmony project.

ECMAScript 5th Edition

ECMAScript 5th Edition isn't as radical as JavaScript 2 was supposed to
be. It's a very different beast. The main changes are relatively

There are also some more fundamental language changes:

Updated Object Model

Object gets a lot of new methods: Object.create, Object.getPrototypeOf,
Object.keys, Object.getOwnPropertyNames, object descriptors,
Object.seal, Object.freeze.

I don't want to write about all of these new Object methods, but
basically: we now have a way of freezing objects, and safely enumerating
over methods that want to be enumerated over.

There's coverage in Enhanced Scripting in IE9: ECMAScript 5 Support and


These methods will give more control to API authors and a greater sense
of control over objects.

Strict mode

use strict; will instruct the interpreter to run with
strict mode. This is a useful way of ensuring that code only uses
ECMAScript features, rather than a dialect:

The strict variant of ECMAScript is commonly referred to as the strict mode of the language. Strict mode selection and use of the strict mode syntax and semantics of ECMAScript is explicitly made at the level of individual ECMAScript code units.


Constants aren't actually in ECMAScript 5, const is marked
as a future reserved word. Some interpreters support it already,
although I wouldn't rely on the behaviour the exhibit being totally

Getters and Setters

The keywords get and set are used to decorate
functions that are getters or setters:

user = {
  first_name: 'Alex',
  last_name: 'Young',

  get full_name() { return this.first_name + ' ' + this.last_name; },

  set full_name(name) {
    name = name.split(' ');
    this.first_name = name[0];
    this.last_name = name[1];

// returns: Alex Young
user.full_name = 'Alex Smith'
// returns: Alex Smith

You can already use this in Rhino and Firefox, as well as V8 and
probably lots of other interpreters.

This is being used out there in the wild, so it's worth getting used to
the syntax.


ECMAScript 5 adds enough syntax sugar to keep developers happy for the
foreseeable future. It also addresses some areas in the object model
that we were left to code for ourselves. The Array and
String changes also add things we've previously had to
patch ourselves. More importantly, these changes combined with use
help in areas where JavaScript interpreters had diverged,
which means hopefully future browsers (and our code) should be more