JS Versions
JavaScript is the implementation of the ECMAScript spec. Each year a new edition adds features. Modern code targets ES2015+ ("ES6") at minimum; everything older is the legacy floor.
The headline editions
| Year | Edition | Big additions |
|---|---|---|
| 2009 | ES5 | "use strict", JSON, Object.create, getters/setters. |
| 2015 | ES6 / ES2015 | let/const, classes, arrows, template literals, modules, Promises, Map/Set, destructuring, default/rest/spread, for…of, generators. |
| 2016 | ES2016 | **, Array.includes. |
| 2017 | ES2017 | async/await, Object.values/entries, string padding. |
| 2018 | ES2018 | Object spread, async iteration, regex improvements. |
| 2019 | ES2019 | flat/flatMap, Object.fromEntries, optional catch binding. |
| 2020 | ES2020 | Optional chaining ?., nullish coalescing ??, BigInt, dynamic import(). |
| 2021 | ES2021 | Numeric separators, replaceAll, Promise.any, logical assignments. |
| 2022 | ES2022 | Class fields + private (#), top-level await, at(), Object.hasOwn, error cause. |
| 2023 | ES2023 | findLast/findLastIndex, non-mutating array methods (toSorted, toReversed, toSpliced, with). |
| 2024+ | ES2024 | Set methods (union, intersection), Promise.withResolvers, structuredClone well-supported. |
What "supported" means
A feature is shipped when the major browser engines (V8, SpiderMonkey, JavaScriptCore) all implement it. Check on caniuse.com or MDN compatibility tables before relying on bleeding-edge syntax.
Polyfills vs. transpilation
| Type of feature | What you need |
|---|---|
New method (e.g. Array.prototype.flat) | A polyfill — code that adds it to older engines. |
| New syntax (e.g. arrow function) | A transpiler (Babel, swc) to rewrite as old syntax. |
New API (e.g. structuredClone) | Polyfill or fallback path. |
Tip: For new projects, target the last 2 major versions of every evergreen browser. Most modern syntax then works natively — Babel only kicks in for the very newest proposals.
Example
Example
<!DOCTYPE html>
<html>
<body>
<p id="out"></p>
<script>
document.getElementById("out").textContent = "Hello from JS Versions!";
</script>
</body>
</html>
Try it Yourself »
Exercise
Name the year that gave us classes, arrows, and modules.
Answer: ES
ES6 or its full year.
Discussion
Loading…