What’s New in ES2017 (or ES8) for JavaScript

The 2017 JavaScript feature release becomes official

Trey Huffine
Jul 24, 2017 · 4 min read

ES8 Features

Async Function

async function getDataFromAjax(url) {
let data;
try {
data = await fetch(url);
// This will wait
// until fetch returns
fillClientStateWithData(data.json());
} catch(error) { // This will execute if the
// API returns an error
handleAjaxError(error);
}
}
getDataFromAjax();

Object.values and Object.entries

const obj = {
me: 'I',
hello: 'love',
js: 'ES8',
secrets: 42
}
const result = Object.values(obj);console.log(result); // ["I", "love", "ES8", 42]
const obj = {
me: 'I',
hello: 'love',
js: 'ES8',
secrets: 42
}
const result = Object.entries(obj);console.log(result); // [["me", "I"], ["hello", "love"], ["js", "ES8"], ["secrets", 42]]

Trailing Commas in Function Parameter Lists

class C {
one(a,) {},
two(a, b,) {},
}

var obj = {
one(a,) {},
two(a, b,) {},
};
function hi(a,b,) {
console.log(`hi ${a} and ${b}`)
}
hi('world', 'es8',);
// Previously implemented legal trailing commas for objects and arraysvar obj = { 
foo: "bar",
baz: "qwerty",
age: 42,
};
var arr = [1,2,3,] // note if you use more than one comma at the end, it will add to the length

String Padding

// padStart
'abc'.padStart(10); // " abc"
'abc'.padStart(10, "foo"); // "foofoofabc"
'abc'.padStart(6,"123465"); // "123abc"
'abc'.padStart(8, "0"); // "00000abc"
'abc'.padStart(1); // "abc"
// padEnd
'abc'.padEnd(10); // "abc "
'abc'.padEnd(10, "foo"); // "abcfoofoof"
'abc'.padEnd(6, "123456"); // "abc123"
'abc'.padEnd(1); // "abc"

Object.getOwnPropertyDescriptors()

const obj = {
hello: 'world',
user: 'turing'
}
const clone = Object.create(
Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj)
);

Shared Memory and Atomics

Conclusion


Engineering Blockchain Jobs >

jsComplete EdgeCoders

We write about the new and leading edge technologies with a focus on JavaScript

Trey Huffine

Written by

Founder of gitconnected.com - Passionate for open source software and teaching people how to code. Learn to code => gitconnected.com/learn

jsComplete EdgeCoders

We write about the new and leading edge technologies with a focus on JavaScript