Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JS 2018

JavaScript Version Numbers

Earlier ECMAScript versions were named by numbers, such as ES5 and ES6. Starting in 2016, versions are named by the year of release, like ES2016, ES2018, ES2020, and so on.

New Features in ECMAScript 2018

This chapter covers the new features introduced in ECMAScript 2018:

  • Asynchronous Iteration
  • Promise.finally()
  • Object Rest Properties
  • New Regular Expression Features
  • JavaScript Shared Memory

JavaScript Asynchronous Iteration

ECMAScript 2018 introduced asynchronous iterators and iterables. With asynchronous iterables, the await keyword can be used inside for/of loops.

Example

for await () {}

JavaScript asynchronous iteration has been supported in all modern browsers since January 2020.

js 15

JavaScript Promise.finally

ECMAScript 2018 completes the full implementation of the Promise object with the addition of Promise.finally().

Example

let myPromise = new Promise();

myPromise.then();
myPromise.catch();
myPromise.finally();

Promise.finally() has been supported in all modern browsers since November 2018.

js 16

JavaScript Object Rest Properties

ECMAScript 2018 introduced rest properties, allowing us to destructure an object and collect the remaining properties into a new object.

Example

let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };
x; // 1
y; // 2
z; // { a: 3, b: 4 }

Object rest properties have been supported in all modern browsers since January 2020.

js 17

New JavaScript RegExp Features

ECMAScript 2018 introduced four new RegExp features:

 

  • Unicode Property Escapes (\p{…})
  • Lookbehind Assertions (?<= and ?<!)
  • Named Capture Groups
  • s (dotAll) Flag

These new RegExp features have been supported in all modern browsers since June 2020.

js 18