New ES2018 Features Every JavaScript Developer Should Know
The article introduces the major ES2018 additions—including rest/spread properties, asynchronous iteration, Promise.prototype.finally, and four RegExp enhancements—explains their syntax and usage with examples, and lists Node.js versions that support each feature, helping developers adopt the latest JavaScript capabilities.
ECMAScript 2018 (ES2018) was officially released in June 2018, adding four new RegExp features, rest/spread properties, asynchronous iteration, and Promise.prototype.finally . The article walks through each feature, shows practical code examples, and notes browser and Node.js support.
Rest/Spread Properties extend the spread operator to objects, allowing shallow copying of enumerable own properties and merging objects without invoking setters. Examples demonstrate replacing Object.assign() and illustrate how non‑enumerable or inherited properties are ignored.
Rest Parameters let functions collect remaining arguments into an array using the ... syntax. The article shows array destructuring and how the same pattern is applied to objects via rest properties, emphasizing that the rest property must appear last.
Asynchronous Iteration introduces for...await...of , async iterators, and the Symbol.asyncIterator method. The text explains how the iterator returns a promise of {value, done} , how to handle rejected promises with try...catch , and why the syntax works only inside async functions or generators.
Promise.prototype.finally provides a clean‑up step that runs after a promise settles, regardless of fulfillment or rejection. The article compares finally() with chaining then() / catch() and shows typical usage in HTTP request handling.
RegExp Enhancements include the s (dotAll) flag, named capture groups (? ...) , lookbehind assertions (?<=...) and (?<!...) , and Unicode property escapes \p{...} / \P{...} . Each feature is illustrated with sample patterns and replacement strings, and the benefits of backward compatibility are highlighted.
Template Literal Revisions remove previous escape‑sequence restrictions in tagged templates, allowing invalid escapes to evaluate to undefined instead of throwing SyntaxError . The article shows a simple tagged‑template example and notes that ordinary template literals still enforce the old rules.
Support tables list the Node.js versions that fully implement each feature (e.g., async iteration fully supported from 10.0.0, rest/spread properties from 8.3.0, finally from 10.0.0, and RegExp features progressively from 8.3.0 to 10.0.0).
In conclusion, ES2018 brings powerful new syntax that modernizes JavaScript development; while some browsers may lag, tools like Babel enable developers to use these features today.
UC Tech Team
We provide high-quality technical articles on client, server, algorithms, testing, data, front-end, and more, including both original and translated content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.