ECMAScript 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
Features Pushed to ES2027
While highly visible in the ecosystem through mature polyfills, a couple of major proposals just missed the June 2026 cutoff for official inclusion and are officially slated for next year's spec:
- Temporal API
The long-time-overdue successor to the buggy, 30-year-old Date object. Unlike Date, Temporal objects are immutable and provide first-class support for time zones and non-Gregorian calendars. - Explicit Resource Management (using keyword)
C#-style block-scoped disposal variables that auto-clean up database connections and streams when leaving context, avoiding try...finally boilerplate.
Accurate Math with Math.sumPrecise()
Math.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
const 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
const 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
<iframe> or a separate runtime sandbox.
Example
Error.isError(new TypeError()); // true
Error.isError({ name: "Error" }); // false
Try it Yourself »
Realm-safe error check:
An Error from an iframe verifies with Error.isError()
and fails with instanceof.
Example
Error.isError() is a safe alternative to
instanceof Error which fails across realms.
try {
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()
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
// 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
async function* asyncGenerator() {
yield Promise.resolve(1);
yield Promise.resolve(2);
yield Promise.resolve(3);
}
async function processAsyncData() {
const arr = await Array.fromAsync(asyncGenerator());
}
processAsyncData();
Try it Yourself »
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
// 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=");
let string = 'W3Schools 123';Try it Yourself »
const arr = Uint8Array.fromBase64(string);const arr = new Uint8Array([91,116,156,134,138,37,179,93,183]);Try it Yourself »
let text = arr.toBase64();Browser Support
to/fromBase64()is supported in all major browsers:Chrome
140Edge
140Firefox
133Safari
18.2Opera
124Sep 2025 Sep 2025 Nov 2024 Des 2024 Nov 2024
Uint8Array to/fromHex()
Examples
let text = '5b749c868a25b35db7';Try it Yourself »
const arr = Uint8Array.fromHex(text);const arr = new Uint8Array([91,116,156,134,138,37,179,93,183]);Try it Yourself »
let text = arr.toHex();Browser Support
to/fromHex()is supported in all major browsers:Chrome
140Edge
140Firefox
133Safari
18.2Opera
124Sep 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
// Old Way: Inaccuracies accumulateTry it Yourself »
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
147Edge
147Firefox
137Safari
26.2Opera
131;Apr 2026 Apr 2026 Apr 2025 Nov 2025 Apr 2026
-->