ES2016 to ES2024

Updated · 9 min read
mediumES2026javascriptecmascriptversionsfeatures

After ES2015, JavaScript switched to one small edition per year. Each brought a handful of features, and together they produced much of what feels "modern" today: async/await, object spread, optional chaining, ??, class fields, Object.groupBy and more. This lesson lists each edition from ES2016 to ES2024 with a short example and a pointer to the lesson that teaches each feature. (ES2025 and ES2026 are covered in "What's New in JavaScript".)

In One Minute

  • ES2017 brought async/await; ES2018 object rest/spread and async iteration; ES2020 ?., ?? and BigInt.
  • ES2022 gave classes fields, #private members and static blocks, plus top-level await and .at().
  • ES2023 added non-mutating array methods (toSorted, with); ES2024 added Object.groupBy and Promise.withResolvers.
  • Every feature here runs in current browsers and Node.js 26.
  • Use this page as a lookup table when you meet a feature in code and want to know how old it is.

ES2016

FeatureExampleLesson
Array.prototype.includes[9, 10].includes(10)"Searching Arrays"
Exponent operator **2 ** 10"Arithmetic and Assignment Operators"
es2016.js▶ Try it
console.log([9, 10, NaN].includes(NaN), 2 ** 10);
Output
true 1024

ES2017

FeatureExampleLesson
async functions and awaitconst data = await load()"Async and Await"
Object.values, Object.entriesObject.entries(fees)"Looping Through Objects"
padStart, padEnd"7".padStart(3, "0")"String Methods"
Object.getOwnPropertyDescriptorsCopying getters and setters"Protecting Objects"
Trailing commas in function parametersf(a, b,)
SharedArrayBuffer, AtomicsShared memory between workers"Typed Arrays and ArrayBuffer"
es2017.js▶ Try it
const fees = { tuition: 400, books: 85 };
const total = Object.values(fees).reduce((a, b) => a + b, 0);
const later = async () => total;
console.log(await later(), Object.entries(fees), "7".padStart(3, "0"));
Output
485 [['tuition', 400], ['books', 85]] 007

ES2018

FeatureExampleLesson
Object rest and spread{ ...defaults, ...settings }"Destructuring and Spread"
Async iteration, for await...offor await (const page of pages())"Generators"
Promise.prototype.finallyp.finally(hideSpinner)"Promises"
RegExp named groups/(?<year>\d{4})/"Regex Groups and Assertions"
RegExp lookbehind/(?<=\$)\d+/"Regex Groups and Assertions"
RegExp s (dotAll) flag/a.b/s"Regular Expressions"
Unicode property escapes/\p{L}+/u"Regular Expressions"
es2018.js▶ Try it
const settings = { ...{ currency: "USD", pageSize: 25 }, pageSize: 50 };
const { year } = "Due 2026-01-05".match(/(?<year>\d{4})/).groups;
console.log(settings, year, "Paid $120".match(/(?<=\$)\d+/)[0]);
Output
{ currency: 'USD', pageSize: 50 } 2026 120

ES2019

FeatureExampleLesson
Array.prototype.flat, flatMap[[1], [2]].flat()"Array Methods: Map, Filter and Reduce"
Object.fromEntriesObject.fromEntries(map)"Looping Through Objects"
trimStart, trimEnd" x ".trimStart()"String Methods"
Optional catch bindingcatch { ... }"Try, Catch and Finally"
Symbol.prototype.descriptionSymbol("id").description"Symbols"
Stable Array.prototype.sort (required)Equal items keep their order"Sorting Arrays"
es2019.js▶ Try it
console.log([[120], [85, [45]]].flat(Infinity), Object.fromEntries([["a", 1]]));
try { JSON.parse("{bad"); } catch { console.log("optional catch binding"); }
Output
[120, 85, 45] { a: 1 }
optional catch binding

ES2020

FeatureExampleLesson
Optional chaining ?.student.address?.city"Logical Operators"
Nullish coalescing ??balance ?? 0"Logical Operators"
BigInt9007199254740993n"BigInt"
Promise.allSettledWait for all, report each"Running Tasks in Parallel"
globalThisThe global object everywhere"How JavaScript Runs"
String.prototype.matchAllAll matches with groups"RegExp Methods"
Dynamic import()await import("./charts.js")"Dynamic Imports and Import Maps"
import.metaimport.meta.url"ES Modules"
es2020.js▶ Try it
const student = { name: "Advitha", balance: 0 };
console.log(student.address?.city ?? "no city", student.balance ?? 100, 2n ** 64n > 0n);
const results = await Promise.allSettled([Promise.resolve(1), Promise.reject(new Error("x"))]);
console.log(results.map((r) => r.status), typeof globalThis);
Output
no city 0 true
['fulfilled', 'rejected'] object

ES2021

FeatureExampleLesson
String.prototype.replaceAll"a-b-c".replaceAll("-", "/")"String Methods"
Promise.any, AggregateErrorFirst success wins"Running Tasks in Parallel"
Logical assignment ||=, &&=, ??=settings.theme ??= "light""Logical Operators"
Numeric separators1_000_000"Numbers"
WeakRef, FinalizationRegistryWeak references"Memory, Cleanup and Garbage Collection"
es2021.js▶ Try it
const s = { pageSize: 0 };
s.pageSize ??= 25;
s.theme ??= "light";
console.log("2026-01-05".replaceAll("-", "/"), s, 1_000_000);
console.log(await Promise.any([Promise.reject(new Error("no")), Promise.resolve("backup")]));
Output
2026/01/05 { pageSize: 0, theme: 'light' } 1000000
backup

ES2022

FeatureExampleLesson
Class fields (public and #private)class A { count = 0; #secret; }"Classes", "Static, Private and Accessor Members"
Private methods and accessors#validate() {}"Static, Private and Accessor Members"
Static fields and static blocksstatic { ... }"Static, Private and Accessor Members"
#field in obj brand checks#id in value"Static, Private and Accessor Members"
Top-level await in modulesconst config = await load()"Async and Await"
.at() on arrays and stringsfees.at(-1)"Arrays", "Strings"
Object.hasOwnObject.hasOwn(obj, "key")"Objects"
Error causenew Error("msg", { cause })"Error Objects and Custom Errors"
RegExp d flag (match indices)/x/d"Regex Groups and Assertions"
es2022.js▶ Try it
class Counter {
  #count = 0;
  static created = 0;
  constructor() { Counter.created++; }
  increment() { return ++this.#count; }
}
const c = new Counter();
c.increment();
console.log(c.increment(), Counter.created, [120, 85, 45].at(-1), Object.hasOwn({ a: 1 }, "a"));
console.log(new Error("Save failed", { cause: new TypeError("bad amount") }).cause.name);
Output
2 1 45 true
TypeError

ES2023

FeatureExampleLesson
findLast, findLastIndexpayments.findLast(isLate)"Searching Arrays"
Change array by copy: toSorted, toReversed, toSpliced, withfees.toSorted((a, b) => a - b)"Sorting Arrays", "Adding and Removing Array Items"
Hashbang grammar#!/usr/bin/env node as the first line
Symbols as WeakMap keysNon-registered symbols as weak keys"WeakMap and WeakSet"
es2023.js▶ Try it
const fees = [120, 45, 85];
console.log(fees.toSorted((a, b) => a - b), fees.with(0, 100), fees.findLast((f) => f > 50), fees);
Output
[45, 85, 120] [100, 45, 85] 85 [120, 45, 85]

ES2024

FeatureExampleLesson
Object.groupBy, Map.groupByObject.groupBy(payments, (p) => p.grade)"Looping Through Objects", "Maps"
Promise.withResolversResolve from outside the executor"Promises"
RegExp v flag (set notation)/[\p{L}--[a-z]]/v"Regular Expressions"
Resizable and transferable ArrayBuffernew ArrayBuffer(8, { maxByteLength: 64 })"Typed Arrays and ArrayBuffer"
String.prototype.isWellFormed, toWellFormedDetect broken UTF-16"Strings"
Atomics.waitAsyncNon-blocking wait on shared memory"Typed Arrays and ArrayBuffer"
es2024.js▶ Try it
const byGrade = Object.groupBy([{ n: "Navika", g: 9 }, { n: "Srihitha", g: 11 }, { n: "Advitha", g: 9 }], (s) => s.g);
console.log(Object.keys(byGrade), byGrade[9].map((s) => s.n));
 
const { promise, resolve } = Promise.withResolvers();
setTimeout(() => resolve("resolved from outside"), 5);
console.log(await promise, "ab\uD800".isWellFormed());
Output
['9', '11'] ['Navika', 'Advitha']
resolved from outside false

At a Glance

EditionHeadline features
ES2016includes, **
ES2017async/await, Object.entries/values, padStart
ES2018Object rest/spread, for await, finally, regex named groups and lookbehind
ES2019flat, flatMap, Object.fromEntries, optional catch binding, stable sort
ES2020?., ??, BigInt, allSettled, globalThis, matchAll, import()
ES2021replaceAll, Promise.any, ??=, numeric separators, WeakRef
ES2022Class fields and #private, static blocks, top-level await, .at(), Object.hasOwn, error cause
ES2023findLast, toSorted, toReversed, toSpliced, with
ES2024Object.groupBy, Map.groupBy, Promise.withResolvers, regex v flag

In Practice

One Fee Tracker function using a feature from almost every edition, with the year marked:

all-years.js▶ Try it
class Ledger {
  #rows = [];                                                       // ES2022 private field
  add(row) { this.#rows.push({ ...row }); return this; }            // ES2018 object spread
  summary() {
    const byName = Object.groupBy(this.#rows, (r) => r.name);       // ES2024
    return Object.entries(byName)                                   // ES2017
      .map(([name, rows]) => [name, rows.reduce((s, r) => s + (r.amount ?? 0), 0)])   // ES2020 ??
      .toSorted(([, a], [, b]) => b - a)                            // ES2023
      .map(([name, total]) => `${name.padEnd(9)}$${total}`);        // ES2017 padEnd
  }
}
 
const ledger = new Ledger().add({ name: "Navika", amount: 120 }).add({ name: "Advitha", amount: 45 }).add({ name: "Navika" });
console.log(ledger.summary().join("\n"), "\n", ledger.summary().at(-1).includes("Advitha"));   // ES2022 at, ES2016 includes
Output
Navika   $120
Advitha  $45
 true

Common Mistakes

Assuming a feature is "too new" without checking. Everything on this page runs in every current browser.

Mixing up similar features from different years. Array spread is ES2015, object spread ES2018; allSettled is ES2020, any ES2021.

Using || where ?? (ES2020) was meant. It replaces 0 and "" too.

Mutating arrays out of habit. Since ES2023, toSorted, toReversed, toSpliced and with return copies.

Practice

Challenge: Rewrite this function using ??, ?., Object.groupBy and toSorted.

practice.js
function countByCity(students) {
  const groups = {};
  students.forEach(function (s) {
    const city = (s.address && s.address.city) || "Unknown";
    groups[city] = (groups[city] || 0) + 1;
  });
  return Object.keys(groups).sort();
}
Show solution
practice-solution.js▶ Try it
const countByCity = (students) =>
  Object.entries(Object.groupBy(students, (s) => s.address?.city ?? "Unknown"))
    .map(([city, list]) => `${city}: ${list.length}`)
    .toSorted();
 
console.log(countByCity([
  { name: "Navika", address: { city: "Dallas" } },
  { name: "Srihitha", address: { city: "San Francisco" } },
  { name: "Advitha", address: { city: "San Francisco" } },
  { name: "Zoe" },
]));
Output
['Dallas: 1', 'San Francisco: 2', 'Unknown: 1']

Quick check: ES2016 to ES2024

3 questions
1Which edition introduced async and await?
2Optional chaining (?.) and nullish coalescing (??) arrived in:
3Which edition added toSorted and with?

Key Takeaways

YearUse it for
2017async/await
2018{ ...obj }, for await
2020?., ??, allSettled
2022#private, at(-1), Object.hasOwn
2023toSorted, with
2024Object.groupBy

Was this tutorial helpful?

Lesson 120 of 139