astradevlabsastradevlabs
← All posts
Dev Tips4 min

The ES2026 Cheat Sheet: 7 New JavaScript Features You Can Use Today

Dev Tips

On June 30, Ecma International approved ECMAScript 2026, the 17th edition of the JavaScript spec. Unlike some years, almost everything in it already ships in current browsers and runtimes — so this is a cheat sheet you can copy from today, not a preview of 2027.

Seven features made the cut. Here's each one, what it replaces, and the snippet to reach for.

The headline: ES2026 is a "delete your utility functions" release. Every entry below kills a helper you've probably written by hand.

1. Array.fromAsync — collect an async iterator into an array

Array.from has handled sync iterables since 2015; async iterables required a manual for await loop. Not anymore:

js
async function* fetchPages(urls) {
  for (const url of urls) yield (await fetch(url)).json();
}

const pages = await Array.fromAsync(fetchPages(urls));

It also accepts a mapping function as the second argument, and it works on sync generators that yield promises. Anywhere you've written const out = []; for await (...) out.push(...), this is the one-liner replacement.

2. Map.prototype.getOrInsert — upsert without the has/set dance

The pattern every cache in your codebase uses — check has, conditionally set, then get — collapses into one call:

js
const cache = new Map();

// before: 3 lines and a branch
// after:
const entry = cache.getOrInsert(key, defaultValue);

There's also getOrInsertComputed(key, fn) on Map and WeakMap for defaults that are expensive to build — the callback only runs on a miss.

3. Uint8Array.toBase64 / fromBase64 — binary encoding without a library

Native Base64 and hex conversion for typed arrays, finally:

js
const bytes = new Uint8Array([69, 83, 50, 48, 50, 54]);

bytes.toBase64();                    // 'RVMyMDI2'
bytes.toHex();                       // '455332303236'
Uint8Array.fromBase64('RVMyMDI2');   // back to bytes

This retires btoa-plus-string-gymnastics hacks and one more npm dependency. If you handle tokens, hashes, or file payloads in the browser, switch to this.

4. Error.isError — instanceof that survives realm boundaries

err instanceof Error returns false when an error crosses an iframe, worker, or vm context boundary, because each realm has its own Error constructor. The new static method checks the actual internal slot:

js
try {
  somethingRisky();
} catch (err) {
  if (Error.isError(err)) console.error(err.message);
  else console.error('Non-error thrown:', err);
}

Use it in any library code that catches values it didn't throw.

5. Iterator.concat — chain iterators without a wrapper generator

Combining iterators used to mean writing a function* that yield*s each source. Now:

js
const merged = Iterator.concat(headerRows, [separator], bodyRows);

Note the middle argument — plain arrays slot in between iterators, which makes injecting sentinel values trivial. This rounds out the iterator-helpers work ES2025 started.

6. JSON.parse source access — BigInts stop silently corrupting

JSON.parse("999999999999999999") quietly rounds to 1000000000000000000. The reviver callback now receives a third argument exposing the raw source text, so you can rescue precision yourself:

js
const id = JSON.parse('999999999999999999',
  (key, value, { source }) => BigInt(source));
// 999999999999999999n

The mirror image is JSON.rawJSON(), which lets a JSON.stringify replacer emit a BigInt as a bare number instead of throwing. If your API sends 64-bit IDs, this pair is the fix you've been working around for years.

7. Math.sumPrecise — floating-point summation that doesn't drift

Summing floats with reduce accumulates rounding error. Math.sumPrecise uses compensated summation internally:

js
const values = [1e20, 0.1, -1e20];

values.reduce((a, b) => a + b, 0);  // 0
Math.sumPrecise(values);            // 0.1

It doesn't repeal IEEE 754 — 0.1 + 0.2 is still not exactly 0.3 — but over long lists of mixed-magnitude numbers the difference is real. One caveat: this is the single ES2026 feature not yet in Node, so check your runtime before shipping it server-side.

The takeaway

  • Safe everywhere now: Array.fromAsync, getOrInsert, Uint8Array Base64/hex, Error.isError, Iterator.concat, JSON source access — all shipping in current browsers and runtimes.
  • Check first: Math.sumPrecise on Node.
  • Do this week: grep your codebase for for await (...push, has(...) + set(...) pairs, and hand-rolled Base64 helpers — each is a deletion waiting to happen.

The spec is 876 pages, but the practical surface is exactly these seven items. Small release, high hit rate.

References