ES8 APIs & Features

ES8 (ECMAScript 2017) introduced async/await for better asynchronous programming, Object methods, and string padding features.

Released: June 2017
Modern JavaScript
ECMAScript

Other JavaScript Versions

Release Information

Release Date:

June 2017

Version Type:
Modern

Quick Summary

ES8 (ECMAScript 2017) introduced async/await for better asynchronous programming, Object methods, and string padding features.

Top Features

  • Async/Await
  • Object.values, Object.entries
  • String padding (padStart, padEnd)
  • Object.getOwnPropertyDescriptors
  • SharedArrayBuffer and Atomics

Playground

Try out JavaScript code examples and experiment with features in the official TypeScript playground.

Open JavaScript Playground

API Examples

Async/Await

Syntactic sugar over promises for writing asynchronous code in a synchronous style.

async function fetchUser(id) {
  try {
    const response = await fetch(`/api/users/${id}`);
    const user = await response.json();
    return user;
  } catch (error) {
    console.error("Error:", error);
  }
}

// Usage
const user = await fetchUser(123);

Object.values & Object.entries

Get array of object values and key-value pairs.

const obj = { a: 1, b: 2, c: 3 };

// Object.values
const values = Object.values(obj); // [1, 2, 3]

// Object.entries
const entries = Object.entries(obj); // [["a", 1], ["b", 2], ["c", 3]]

// Iterate over entries
for (const [key, value] of entries) {
  console.log(`${key}: ${value}`);
}

String Padding

Pad strings to a specified length with characters.

const str = "5";

// padStart - pad at the beginning
console.log(str.padStart(3, "0")); // "005"
console.log(str.padStart(5, "*")); // "****5"

// padEnd - pad at the end
console.log(str.padEnd(3, "0")); // "500"
console.log(str.padEnd(5, "*")); // "5****"