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 const

Backtick strings

Interpolation

const message = `Hello ${name}`

Multiline strings

Templates and multiline strings. See: Template strings

Binary and octal literals

See: Binary and octal literals

New methods

New string methods

Classes

Constructor

Methods

Calling superclass methods

Static methods

Syntactic sugar for prototypes. See: Classes

Promises

Making promises

For asynchronous programming. See: Promises

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 function

Destructuring

De-structuring assignment

Arrays

Objects

Supports for matching arrays and objects. See: Destructuring

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 spread

Array spread

with Array spread

without Array spread

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

See: Spread operator

Functions

Function arguments

Default arguments

Rest arguments

Spread

Default, rest, spread. See: Function arguments

Fat arrows

With arguments

Implicit return

Like functions but with this preserved. See: Fat arrows

Objects

Shorthand syntax

See: Object literal enhancements

Methods

See: Object literal enhancements

Getters and setters

See: Object literal enhancements

Computed property names

See: Object literal enhancements

Extract values

Modules

Imports

import is the new require(). See: Module imports

Exports

export is the new module.exports. See: Module exports

Generators

Generators

It’s complicated. See: Generators

For..of iteration

For iterating through generators and arrays. See: For..of iteration

Last updated

Was this helpful?