This README file provides detailed updates and explanations for ECMAScript (JavaScript) versions 6 through 13. Each version brought powerful new syntax, methods, and paradigms to modern JavaScript development.
letandconst: Block-scoped variable declarations replacingvar.- Arrow Functions (
=>): Shorter syntax, lexicalthisbinding. - Template Literals: Use backticks (``) to embed variables using
${}. - Destructuring: Extract values from arrays/objects.
- Default Parameters: Assign default values in function definitions.
- Rest/Spread Operator (
...): Group/ungroup values. - Enhanced Object Literals: Property shorthand, method definitions.
- Classes: Syntactic sugar over prototype-based inheritance.
- Modules:
import/exportsyntax for modular JavaScript. - Promises: Handle asynchronous operations with
.then()and.catch(). - New Data Structures:
Map,Set,WeakMap,WeakSet. - Symbols: New primitive for unique identifiers.
- Iterators & Generators: Custom iteration logic with
yield. for...ofLoop: Iterate over iterable objects (e.g., arrays).
Array.prototype.includes(): Checks if array includes a value.- Exponentiation Operator (
**):2 ** 3is equivalent toMath.pow(2, 3).
async/await: Syntactic sugar over Promises for readable async code.Object.values()/Object.entries(): Convert object to arrays.padStart()/padEnd(): Pad strings to a certain length.Object.getOwnPropertyDescriptors(): Fetch all property descriptors.- Trailing Commas in Functions: Avoid syntax errors during edits.
- Rest/Spread Properties for Objects: Copy and extract object properties.
- Asynchronous Iteration (
for await...of): Iterate over async iterables. Promise.prototype.finally(): Run code after promise settles.- RegExp Enhancements:
- Lookbehind assertions:
/(?<=prefix)word/ - Named capture groups:
/(?<year>\d{4})/ - DotAll flag (
/s):.matches newline characters
- Lookbehind assertions:
Array.prototype.flat()/flatMap(): Flatten nested arrays.Object.fromEntries(): Convert key-value array to object.trimStart()/trimEnd(): Trim whitespace.- Optional Catch Binding:
catch {}without parameter. - Symbol Description:
Symbol('desc').descriptionreturns'desc'.
- Optional Chaining (
?.): Safe access to deeply nested properties. - Nullish Coalescing (
??): Default only whennullorundefined. - BigInt: Arbitrary-precision integers (
12345678901234567890n). Promise.allSettled(): Wait for all promises regardless of result.globalThis: Universal global object across environments.- Dynamic
import(): Load modules dynamically. import.meta: Metadata about current module.matchAll(): Returns all regex matches with capturing groups.- Ordered
for-in: Property order guarantee.
- Logical Assignment Operators:
||=: Assign if falsy&&=: Assign if truthy??=: Assign if nullish
- Numeric Separators: Improve readability (e.g.,
1_000_000). String.prototype.replaceAll(): Replace all occurrences.- WeakRefs & Finalizers: Advanced memory management tools.
Promise.any(): Resolves as soon as one promise fulfills.AggregateError: Errors fromPromise.any().
- Top-Level
await: Useawaitoutside async functions in modules. - Class Fields:
- Public:
name = 'value' - Private:
#id = 123
- Public:
.at()Method: Access index likearr.at(-1).Object.hasOwn(): Safer alternative tohasOwnProperty().- Error Cause: Pass underlying error to new error instance.
- RegExp Match Indices (
/d): Returns match start/end positions.
| ES Version | Year | Key Features |
|---|---|---|
| ES6 | 2015 | Classes, Modules, Promises |
| ES7 | 2016 | includes(), ** operator |
| ES8 | 2017 | async/await, object methods |
| ES9 | 2018 | Rest/spread objects, RegEx improvements |
| ES10 | 2019 | flat(), fromEntries(), trimStart() |
| ES11 | 2020 | Optional chaining, BigInt, allSettled() |
| ES12 | 2021 | replaceAll(), logical assignment, Promise.any() |
| ES13 | 2022 | Class fields, .at(), top-level await |