JS Tutorial
JS Version
JS Objects
JS Function
JS Classes
JS Async
JS HTML DOM
JS Browser BOM
JS Web API
JS AJAX
JS JSON
JS vs JQUERY
JS Graphics
ECMAScript 2018
The JavaScript naming convention started with ES1, ES2, ES3, ES5, and ES6.
But, ECMAScript 2016 and 2017 were not called ES7 and ES8.
Since 2016 new versions are named by year (ECMAScript 2016 / 2017 / 2018).
New Features in ECMAScript 2018
- Asynchronous Iteration.
- Promise Finally.
- Object Rest Properties.
- New RegExp Features.
- JavaScript Asynchronous Iteration.
Asynchronous iterators and iterables were added in ECMAScript 2018.
With asynchronous iterables, use the await keyword in for/of loops.
Example
for await () {}
JavaScript Promise. finally
ECMAScript 2018 uses the full implementation of the Promise object with Promise.finally:
Example
let myPromise = new Promise();
myPromise.then();
myPromise.catch();
myPromise.finally();
JavaScript Object Rest Properties
ECMAScript 2018 added rest properties.
This enables the user to destruct an object and collect the leftovers onto 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 }
New JavaScript RegExp Features
ECMAScript 2018 added four new RegExp features:
- Unicode Property Escapes (\p{…})
- Lookbehind Assertions (?<= ) and (?<! )
- Named Capture Groups
- s (dotAll) Flag.