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 Feature Example Lesson Array.prototype.includes[9, 10].includes(10)"Searching Arrays" Exponent operator ** 2 ** 10"Arithmetic and Assignment Operators"
console .log ([9 , 10 , NaN ].includes (NaN ), 2 ** 10 ); ES2017 Feature Example Lesson 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 parameters f(a, b,)SharedArrayBuffer, AtomicsShared memory between workers "Typed Arrays and ArrayBuffer"
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 Feature Example Lesson 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"
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 Feature Example Lesson 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 binding catch { ... }"Try, Catch and Finally" Symbol.prototype.descriptionSymbol("id").description"Symbols" Stable Array.prototype.sort (required) Equal items keep their order "Sorting Arrays"
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 Feature Example Lesson Optional chaining ?. student.address?.city"Logical Operators" Nullish coalescing ?? balance ?? 0"Logical Operators" BigInt 9007199254740993n"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"
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 Feature Example Lesson 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 separators 1_000_000"Numbers" WeakRef, FinalizationRegistryWeak references "Memory, Cleanup and Garbage Collection"
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 Feature Example Lesson 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 blocks static { ... }"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 cause new Error("msg", { cause })"Error Objects and Custom Errors" RegExp d flag (match indices) /x/d"Regex Groups and Assertions"
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 Feature Example Lesson 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 lineSymbols as WeakMap keys Non-registered symbols as weak keys "WeakMap and WeakSet"
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 Feature Example Lesson 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 ArrayBuffer new 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"
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 The features you'll use most from these years: async/await (2017), object spread (2018), ?. and ?? (2020), class fields and #private (2022), toSorted and friends (2023), Object.groupBy (2024).
At a Glance Edition Headline features ES2016 includes, **ES2017 async/await, Object.entries/values, padStartES2018 Object rest/spread, for await, finally, regex named groups and lookbehind ES2019 flat, flatMap, Object.fromEntries, optional catch binding, stable sortES2020 ?., ??, BigInt, allSettled, globalThis, matchAll, import()ES2021 replaceAll, Promise.any, ??=, numeric separators, WeakRefES2022 Class fields and #private, static blocks, top-level await, .at(), Object.hasOwn, error cause ES2023 findLast, toSorted, toReversed, toSpliced, withES2024 Object.groupBy, Map.groupBy, Promise.withResolvers, regex v flag
When you find an unfamiliar feature in a codebase, its edition year tells you roughly how widely supported it is: anything here is in every current browser, and ES2020 and earlier run even in fairly old ones.
In Practice One Fee Tracker function using a feature from almost every edition, with the year marked:
class Ledger {
#rows = [];
add (row ) { this .#rows.push ({ ...row }); return this ; }
summary ( ) {
const byName = Object .groupBy (this .#rows, (r ) => r.name );
return Object .entries (byName)
.map (([name, rows] ) => [name, rows.reduce ((s, r ) => s + (r.amount ?? 0 ), 0 )])
.toSorted (([, a], [, b] ) => b - a)
.map (([name, total] ) => `${name.padEnd(9 )} $${total} ` );
}
}
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" ));
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 Copy
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
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'] Key Takeaways
Yearly editions added a few features each; together they define modern JavaScript.
Key years: 2017 (async/await), 2018 (object spread), 2020 (?., ??, BigInt), 2022 (class fields, private members, top-level await).
ES2023 and ES2024 added copying array methods, Object.groupBy and Promise.withResolvers.
Everything here runs in current browsers and Node.js 26.
Year Use it for 2017 async/await2018 { ...obj }, for await2020 ?., ??, allSettled2022 #private, at(-1), Object.hasOwn2023 toSorted, with2024 Object.groupBy