You will understand how ECMAScript versions define JavaScript features, why yearly releases do not guarantee browser support, and how to choose a safe target for your code.
What it is
ECMAScript is the standard that defines the core JavaScript language. It is maintained by Ecma International through the TC39 committee. JavaScript engines such as V8, SpiderMonkey, and JavaScriptCore implement the standard, but they may add features at different times.
Old editions used numbers like ES5. Since ES2015, also called ES6, the standard has released a new edition almost every year: ES2016, ES2017, ES2020, ES2022, ES2024, and so on. Each edition is a snapshot of features that reached Stage 4 in the TC39 proposal process. Related terms include proposal, polyfill, transpiler, and target.
Why it matters
- It tells you which syntax and built-in methods are part of the language standard.
- It helps you choose a compatibility target for browsers, Node.js, or embedded devices.
- It explains why code can be valid JavaScript but still fail on an older engine.
- It guides decisions about transpilers such as Babel or TypeScript and polyfills such as core-js.
Syntax or steps
There is no single syntax for "using an ECMAScript version." Instead, you write code with features from a chosen edition and configure tools to support your target.
- Pick the oldest environment you must support.
- Check which ECMAScript features that environment implements.
- Use newer syntax only if it is supported or transpiled.
- Add polyfills for missing built-ins, not just syntax.
Example
// ES2015: const and arrow functions
const users = [
{ name: "Ada", active: true },
{ name: "Linus", active: false }
];
const activeNames = users.filter(user => user.active).map(user => user.name);
console.log(activeNames); // ["Ada"]
// ES2020: optional chaining and nullish coalescing
const settings = { theme: null };
const theme = settings?.theme ?? "light";
console.log(theme); // "light"
// ES2022: private class fields
class Counter {
#count = 0;
increment() { this.#count += 1; }
get value() { return this.#count; }
}
const counter = new Counter();
counter.increment();
console.log(counter.value); // 1
The example mixes features from different editions to show how the language has grown.
constand arrow functions are ES2015-era features;filterandmapare older array methods.?.themesafely reads a property only ifsettingsexists.??uses the right side only when the left side isnullorundefined.#countis a private class field, so outside code cannot read or write it directly.
Common mistakes
- Assuming ES2024 means every browser supports ES2024. Fix: check engine support or use a compatibility table.
- Confusing ES6 with ES2016. Fix: remember ES6 is another name for ES2015; ES2016 is the next yearly edition.
- Using a transpiler and thinking all built-ins are fixed. Fix: transpilers rewrite syntax; polyfills add missing methods like
Object.groupBy. - Writing code for the latest edition in a legacy environment. Fix: set a conservative target and let tools transform newer syntax.
When to use it
Use ECMAScript edition knowledge when deciding what JavaScript features are safe to write. Compare it with engine support: the edition says what the standard includes, while the engine says what a runtime actually implements.
| Choice | Use when | Trade-off |
|---|---|---|
| Latest ECMAScript syntax | Modern browsers or controlled Node.js environments | Less code, but older runtimes may fail to parse it |
| Older target with transpilation | Broad compatibility is required | More build complexity and larger output |
| Polyfills for specific features | You need a newer built-in in an older runtime | Extra code size and possible edge cases |
Practice
- Guided exercise: Write an expression that reads
user.address.citysafely and returns"Unknown"if any part is missing. Expected output forconst user = { address: {} };is"Unknown". - Challenge: Create a class named
BankAccountwith a private field#balance, a methoddeposit(amount), and a getterbalance. Hint: use ES2022 private fields.
Quick check
Why can Object.groupBy be part of ES2024 but still unavailable in some browsers?
Because ECMAScript defines the standard, while each browser engine decides when to implement it. You may need a polyfill or a support check.
Summary
ECMAScript versions are yearly snapshots of standardized JavaScript features. They help you reason about language capabilities, but real compatibility depends on the engine and runtime. Choose a target, transpile syntax when needed, and polyfill missing built-ins.