About ECMAScript

Familiar syntax

ECMAScript's syntax is similar to other popular programming languages such as Java and C. This means that many common programming idioms look familiar in ECMAScript.

for(i = 0; i < a.length; i++) {
    if (a[i] == x)
        return i;

Object-oriented programming

ECMAScript supports object-oriented programming. Objects in ECMAScript are values with named properties. Object properties that are functions can be called as methods.


Functions are objects, too!

ECMAScript functions are objects and can be stored as properties, passed as arguments, and returned as results. This powerful idiom from functional programming allows your functions and methods to import functionality from their caller in a simple and flexible way.

var recent = posts.sort(function(a, b) {
                            return (a.date > b.date ? -1 : 1);
                        }).slice(0, 10);

Objects have prototypes

Inspired by the Self programming language, ECMAScript objects inherit properties from prototype objects. Prototype-based programming facilitates easy delegation and flexible overriding of object behavior.

function Car() { }
Car.prototype = new Object();
Car.prototype.wheels = 4;
Car.prototype.color = "black";

function RaceCar() { }
RaceCar.prototype = new Car();
RaceCar.prototype.color = "red";

var vroom = new RaceCar();
vroom.wheels // 4
vroom.color  // "red"

Convenient data constructors

ECMAScript comes with many shorthands for common datatypes, which saves you time and makes your programs much more readable.


var digits = [3, 1, 4, 1, 5, 9];


var img = { width: 320, height:160, src: "images/es.png" };

Regular Expressions

var email = /([^@]*)@([^@]*)/;

JavaScript Object Notation (JSON)

JSON is a popular, lightweight data interchange format. JSON is particularly useful for interactive web pages and web services, in part because its syntax is a subset of the ECMAScript syntax.

Fifth Edition

Ecma has recently announced the final candidate draft of the new Fifth Edition of the ECMAScript standard. Some of the new features include:

  • Improved standard libraries
  • Standardized JSON library
  • Reflective getters and setters

What's next?

The TC39 committee is actively working on the future of ECMAScript. Some of the proposals under discussion include: