JS: 2015 Features

By Xah Lee. Date: . Last updated: .

What is ECMAScript 2015

Over 10 major features are added to the language, effectively making JavaScript a new language.

Here is a quick overview of new features.


let is like var , but with a clean block-level scope.


const is for declaring constants. It's similar to let, except you can't change its value once set.

Arrow Function

you can write function like this

((x, y) => { return x + y; });

but no this Binding , and no arguments Object, no Function Name Hoisting .

Function Argument Default Values

function parameter can specify a default value.

Rest Parameters

function can now specify to take any number of parameters, by syntax ...args

Destructuring Assignment

// destructuring assignment
let [x, y, z] = [3, 4, 6];

Object Literal Expression, Computed Property Keys

new syntax for object literal to have computed property key by an expression.

obj = {[expression]:value}

Object Literal Expression, Method Definition Shorthand

new syntax shorthand for defining methods in object literal expression.

obj = { method_name() {body}, etc };


Allow the use of property key __proto__ to get/set parent.

Template String

allows you to embed variable or expression in a string, or have newline char.

Spread Operator

The spread operator is 3 dots followed by a array, like this: ...arrayX. What it does is effectively remove the bracket of the array.

for-of Loop

for-of loop lets you properly loop thru an array, or new datatypes such as set and map, or any iterable object. Iterable object is a new concept, created just for for-of loops.

Interface, Iterable, Iterator, Generator

Set Object

Set object lets you have a data structure of set. That is, a collection of unique values.

// create a set, add value to it
var s = new Set();
console.log(s); // Set { '5', '6' }

Map Object

Map object lets you have a data structure of key value pairs. Map object is similar to Python's dictionary or Ruby's hash. Similar to JavaScript Object, but now designed to be used as a data structure.

const m = new Map();

// add new item
m.set(1, "n1");
m.set(2, "n2");

console.log(m); // Map { 1 => 'n1', 2 => 'n2' }


The Reflect object is used as namespace to host a group of static functions. Reflect methods typically duplicate operator behavior in function form, or provides a more strict or improved version of existing methods.


class is a new keyword that lets you conveniently define object and its prototype.

New keywords are: class, constructor, static, extends, super.


New regex flag "u". For unicode. Treat string as sequence of unicode characters.

New regex flag "y". For “sticky”. This means next regex match call will start with lastIndex.

New value properties.

New function properties.

New Array Properties

new array constructor properties

new array prototype properties

New String Properties

static methods

string methods

New Object Methods

New Function Properties

function property "name"

New Number Properties

new Math methods

html-like comments

block-level function declaration

// es2015 block-level function declaration

function f() {
  function g(x) {
    return x + 1;
  return g(1);

console.log(f()); // 2

Module, Keyword “import”, “export”


Unicode Escape Syntax

Now you can escape unicode by \u{4_to_6_hex_digits}




Promise Tutorial



Annex b


ECMAScript 2015 §Structured Data#sec-arraybuffer-objects

dataview object

ECMAScript 2015 §Structured Data#sec-dataview-objects

tail call optimisation (recursion)

ECMAScript 2015 §ECMAScript Language: Functions and Classes#sec-tail-position-calls


ECMAScript 2015 §Keyed Collection#sec-weakset-objects


ECMAScript 2015 §Keyed Collection#sec-weakmap-constructor

BUY ΣJS JavaScript in Depth