Sitemap
Better Programming

Advice for programmers.

JavaScript ES2018 Features With Examples

ES2018 a.k.a. ES9 features

4 min readJan 19, 2020

--

Press enter or click to view image in full size
Image
Photo by Nijwam Swargiary on Unsplash

Today, we’re going to look at ECMAScript features from 2015:

Introduction

ES2018, a.k.a. ES9, is the version of ECMAScript corresponding to the year 2018. This version does not include as many new features as those that appeared in ES6 (2015). However, some useful features have been incorporated.

This article introduces the features provided by ES2018 in easy code examples. In this way, you can quickly understand the new features without the need for a complex explanation.

Of course, it is necessary to have a basic knowledge of JavaScript to fully understand the best ones introduced.

The new JavaScript features in ES2018 are:

  • Lifting template literal restriction.
  • s (dotAll) flag for regular expressions.
  • Regexp named capture groups.
  • Rest/spread properties.
  • Regexp lookbehind assertions.
  • Regexp Unicode property escapes.
  • Promise.prototype.finally.
  • Asynchronous iteration.

Lifting Template Literal Restriction

The proposed solution is to set the cooked value to undefined for template values that contain illegal escape sequences.

The raw value is still accessible via .raw so embedded DSLs that might contain undefined cooked values can just use the raw string:

Press enter or click to view image in full size
Image

s (dotAll) Flag for Regular Expressions

Currently, the dot (.) in regular expressions doesn't match line terminator characters (before ES2018). The proposal specifies the regular expression flag /s.

--

--

Carlos Caballero
Carlos Caballero

Written by Carlos Caballero

Hi! My name is Carlos Caballero and I’m PhD. in Computer Science from Málaga, Spain. Teaching developers and degree/master computer science how to be experts!

No responses yet