ES2015 | 16 Quick Recap

A quick overview of new JavaScript features in ES2015, ES2016, ES2017, ES2018 and beyond.

Block scoping

Let

function fn () {
  let x = 0
  if (true) {
    let x = 1 // only inside this `if`
  }
}
 
 

Const

const a = 1

let is the new var. Constants work just like let, but can’t be reassigned. See: Let and constarrow-up-right

Backtick strings

Interpolation

const message = `Hello ${name}`

Multiline strings

Templates and multiline strings. See: Template stringsarrow-up-right

Binary and octal literals

See: Binary and octal literalsarrow-up-right

New methods

New string methods

Classes

Constructor

Methods

Calling superclass methods

Static methods

Syntactic sugar for prototypes. See: Classesarrow-up-right

Promises

Making promises

For asynchronous programming. See: Promisesarrow-up-right

Using promises

Using promises with finally

The handler is called when the promise is fulfilled or rejected.

Promise functions

Async-await

async functions are another way of using functions.

See: async functionarrow-up-right

Destructuring

De-structuring assignment

Arrays

Objects

Supports for matching arrays and objects. See: Destructuringarrow-up-right

Default values

Default values can be assigned while destructuring arrays or objects.

Function arguments

Destructuring of objects and arrays can be also be done in function arguments.

Default values

Reassigning keys

This example assigns x to the value of the leftkey.

Loops

The assignment expressions work in loops, too.

Object de-structuring

Extract some keys individually and remaining keys in the object using rest (…) operator

Spread

Object spread

with Object spread

without Object spread

The Object spread operator lets you build new objects from other objects.

See: Object spreadarrow-up-right

Array spread

with Array spread

without Array spread

The spread operator lets you build new arrays in the same way.

See: Spread operatorarrow-up-right

Functions

Function arguments

Default arguments

Rest arguments

Spread

Default, rest, spread. See: Function argumentsarrow-up-right

Fat arrows

With arguments

Implicit return

Like functions but with this preserved. See: Fat arrowsarrow-up-right

Objects

Shorthand syntax

See: Object literal enhancementsarrow-up-right

Methods

See: Object literal enhancementsarrow-up-right

Getters and setters

See: Object literal enhancementsarrow-up-right

Computed property names

See: Object literal enhancementsarrow-up-right

Extract values

Modules

Imports

import is the new require(). See: Module importsarrow-up-right

Exports

export is the new module.exports. See: Module exportsarrow-up-right

Generators

Generators

It’s complicated. See: Generatorsarrow-up-right

For..of iteration

For iterating through generators and arrays. See: For..of iterationarrow-up-right

Last updated

Was this helpful?