ES2018 / ES9 feature list and examples

A comprehensive list of ES9 feature list and examples.

ES2018 “ES9” includes the following feature proposals:

Lists and examples for es9 features

Async iterators

Async iterators are like iterators, but this time, next() returns a promise. This promise resolves with the tuple { value, done }. A promise needs to be returned because, at the time, the iterator returns the values of value and done are unknown.

function asyncIterator() {
  const array = [1, 2];
  return {
    next: function() {
      if (array.length) {
        return Promise.resolve({
          value: array.shift(),
          done: false
      } else {
        return Promise.resolve({
          done: true

var iterator = asyncIterator();

(async function() {
    await; // { value: 1, done: false }
    await; // { value: 2, done: false }
    await; // { done: true }

Object rest properties

Rest properties for object destructuring assignment.

let { fname, lname, } = { fname: "Hemanth", lname: "HM", location: "Earth", type: "Human" };
fname; //"Hemanth"
lname; //"HM"
rest; // {location: "Earth", type: "Human"}

Object spread properties

Spread properties for object destructuring assignment.

let info = {fname, lname,};

info; // { fname: "Hemanth", lname: "HM", location: "Earth", type: "Human" }

Promise prototype finally

Promise API is extended by an optional finally block which is called in any case (after the Promise is resolved or is rejected).

function testFinally() {
  return new Promise((resolve,reject) => resolve())

testFinally().then(() => console.debug("resolved")).finally(() => console.debug("finally"))
// resolved
// finally

Credits: Dietmar Aumann

Latest posts by W3TWEAKS (see all)


Leave a Reply

Your email address will not be published. Required fields are marked *