ECMAScript 2026
ECMAScript 2026 (ES2026), the 17th edition of the JavaScript language specification, was officially ratified by ECMA International on June 30, 2026.
New Features in JavaScript 2026
ECMAScript 2026 (ES2026), the 17th edition of the JavaScript language specification, was officially ratified by ECMA International on June 30, 2026.
- Accurate Math with Math.sumPrecise()
- Error detection with Error.isError()
- Asynchronous array creation with Array.fromAsync()
- Map upsert with getOrInsert()
- High-precision JSON with rawJSON()
- Base64 and hexadecimal encodings for Uint8Array
Accurate Math with Math.sumPrecise()
[Math.sumPrecise()](js_2026.asp?#mark_sumprecise) fixes the classic 0.1 + 0.2 === 0.30000000000000004 floating-point problem when summing lists of numbers.
Computers do not think in base-10 decimals like humans; they think in binary bits, which causes structural math flaws in programming.
The Problem: In JavaScript, 0.1 + 0.2 has historically equaled 0.30000000000000004 due to floating-point rounding errors. This is dangerous for financial apps.
The Fix: Math.sumPrecise changes how the underlying language engine calculates a list of decimals, bypassing the system's structural limitation to deliver a perfect sum.
Map Upsert with getOrInsert()
Map.prototype.getOrInsert removes the boilerplate of checking if a key exists before adding an item to a Map structure.
A data structure (like an Array or a Map) holds your information. Previously, JavaScript's built-in structures lacked common-sense shortcuts found in other languages.
The Problem: If you wanted to update a dictionary (Map), you had to write an if statement to check if the key existed, create it if missing, and then update it.
The Fix: Map.prototype.getOrInsert lets you find or create data in one quick move. It expands what the data structure can do natively.
Example
Example Code
javascriptconst userRoles = new Map();
// Old Way: Multi-line checks
if (!userRoles.has("admin")) {
userRoles.set("admin", []);
}
userRoles.get("admin").push("Alice");
// New ES2026 Way: Single-line default insertion
userRoles.getOrInsert("admin", []).push("Bob");
userRoles.getOrInsert("admin", []).push("Charlie");
console.log(userRoles.get("admin")); // ['Bob', 'Charlie']High-Precision JSON with rawJSON()
JSON.rawJSON preserves large numbers (like ID strings from databases) without losing digits due to internal rounding.
Example
Example Code
javascriptconst precisionLossJSON = '{"id": 9223372036854775807}';
// New ES2026 Reviver: Accesses the raw source string before rounding
const data = JSON.parse(precisionLossJSON, (key, value, context) => {
if (key === 'id') {
return context.source; // "9223372036854775807" as a string
}
return value;
});
// New ES2026 Stringify: Outputs the unrounded big integer safely
const output = JSON.stringify({
id: JSON.rawJSON("9223372036854775807")
});Error.isError()
Error.isError() is a static method to reliably check if a value is an Error object, improving error handling and debugging.
Error.isError() reliably detects error objects even if they originated from inside an or a separate runtime sandbox.
Example
Example Code
javascriptError.isError(new TypeError()); // true
Error.isError({ name: "Error" }); // falseRealm-safe error check: An Error from an iframe verifies with Error.isError() and fails with instanceof.
Example
Example Code
javascripttry {
throw new TypeError("Invalid format");
} catch (err) {
// Old Way: Could fail across different window contexts
console.log(err instanceof Error);
// New ES2026 Way: Globally reliable
console.log(Error.isError(err)); // true
}Browser Support
Error.isError() is already supported in many browsers:
| Chrome 134 | Edge 134 | Firefox 138 | Safari ❌ | Opera 119 |
| Mar 2025 | Mar 2025 | Apr 2025 | ❌ | May 2025 |
Array.fromAsync()
[Array.fromAsync()](js_2026.asp?#mark_fromasync) is a feature that allows developers to create a new Array instance from asynchronous iterables, array-like objects, or Promises, streamlining the handling of data from async sources.
Example
Example Code
javascript// An async generator simulating a paginated API
async function* fetchPages() {
yield;
yield;
}
// New ES2026 Way: Resolves and flattens natively
const allData = await Array.fromAsync(fetchPages(), flatMap => flatMap);
console.log(allData); // [1, 2, 3, 4]Example
Example Code
javascriptasync function* asyncGenerator() {
yield Promise.resolve(1);
yield Promise.resolve(2);
yield Promise.resolve(3);
}
async function processAsyncData() {
const arr = await Array.fromAsync(asyncGenerator());
}
processAsyncData();Browser Support
Array.fromAsync() is supported in all major browsers:
| Chrome 121 | Edge 121 | Firefox 115 | Safari 16.4 | Opera 107 |
| Jan 2024 | Jan 2024 | Jul 2023 | May 2023 | Feb 2024 |
New Uint8Array Methods
Base64 and Hexadecimal Encodings for Uint8Array.
These new static methods facilitate working with binary data by adding direct conversion between Uint8Array objects and Base64 or hexadecimal strings.
This eliminates the need for external buffer modules or hacky window methods like btoa() and atob().
- Uint8Array fromBase64() Creates a Uint8Array object from a base64-encoded string
- Uint8Array toBase64() Returns a base64-encoded string from the data in an int8Array
- Uint8Array fromHex() Creates a Uint8Array object from a hexadecimal string
- Uint8Array toHex() Returns a hex-encoded string from the data in an int8Array
Uint8Array to/fromBase64()
Examples
Example Code
javascript// Creating raw binary data
const bytes = new Uint8Array([72, 101, 108, 108, 111]); // "Hello"
// New ES2026: Direct string conversions
const base64String = bytes.toBase64();
console.log(base64String); // "SGVsbG8="
const hexString = bytes.toHex();
console.log(hexString); // "48656c6c6f"
// Reversing the operation
const restoredBytes = Uint8Array.fromBase64("SGVsbG8=");Browser Support
to/fromBase64() is supported in all major browsers:
| Chrome 140 | Edge 140 | Firefox 133 | Safari 18.2 | Opera 124 |
| Sep 2025 | Sep 2025 | Nov 2024 | Des 2024 | Nov 2024 |
Uint8Array to/fromHex()
Examples
Example Code
javascriptlet text = '5b749c868a25b35db7';
const arr = Uint8Array.fromHex(text);Browser Support
to/fromHex() is supported in all major browsers:
| Chrome 140 | Edge 140 | Firefox 133 | Safari 18.2 | Opera 124 |
| Sep 2025 | Sep 2025 | Nov 2024 | Des 2024 | Nov 2025 |
Accurate Floating-Point Math
The Math.sumPrecise() Method fixes the classic 0.1 + 0.2 === 0.30000000000000004 floating-point problem when summing lists of numbers.
Example
Example Code
javascript// Old Way: Inaccuracies accumulate
const items = [0.1, 0.2, 0.3];
const badSum = items.reduce((a, b) => a + b, 0);
myDisplayer(badSum);
// New ES2026 Way: Perfectly precise
const preciseSum = Math.sumPrecise(items);
myDisplayer(preciseSum);Browser Support
Math.sumPrecise() is supported in all major browsers:
| Chrome 147 | Edge 147 | Firefox 137 | Safari 26.2 | Opera 131; |
| Apr 2026 | Apr 2026 | Apr 2025 | Nov 2025 | Apr 2026 |
Interactive Code Examples
JS Example 1
javascriptconst userRoles = new Map();
// Old Way: Multi-line checks
if (!userRoles.has("admin")) {
userRoles.set("admin", []);
}
userRoles.get("admin").push("Alice");
// New ES2026 Way: Single-line default insertion
userRoles.getOrInsert("admin", []).push("Bob");
userRoles.getOrInsert("admin", []).push("Charlie");
console.log(userRoles.get("admin")); // ['Bob', 'Charlie']JS Example 2
javascriptconst precisionLossJSON = '{"id": 9223372036854775807}';
// New ES2026 Reviver: Accesses the raw source string before rounding
const data = JSON.parse(precisionLossJSON, (key, value, context) => {
if (key === 'id') {
return context.source; // "9223372036854775807" as a string
}
return value;
});
// New ES2026 Stringify: Outputs the unrounded big integer safely
const output = JSON.stringify({
id: JSON.rawJSON("9223372036854775807")
});JS Example 3
javascriptError.isError(new TypeError()); // true
Error.isError({ name: "Error" }); // falseJS Example 4
javascripttry {
throw new TypeError("Invalid format");
} catch (err) {
// Old Way: Could fail across different window contexts
console.log(err instanceof Error);
// New ES2026 Way: Globally reliable
console.log(Error.isError(err)); // true
}JS Example 5
javascript// An async generator simulating a paginated API
async function* fetchPages() {
yield;
yield;
}
// New ES2026 Way: Resolves and flattens natively
const allData = await Array.fromAsync(fetchPages(), flatMap => flatMap);
console.log(allData); // [1, 2, 3, 4]JS Example 6
javascriptasync function* asyncGenerator() {
yield Promise.resolve(1);
yield Promise.resolve(2);
yield Promise.resolve(3);
}
async function processAsyncData() {
const arr = await Array.fromAsync(asyncGenerator());
}
processAsyncData();