ECMAScript 2025
Here are the officially standardized new features in ECMAScript 2025 (approved June 25 2025), each with a brief overview and a compact example:
1. ✅ Iterator Helper Methods
Overview: Adds Iterator.from() and instance methods (map, filter, drop, take, flatMap, reduce, forEach, some, every, find, toArray) for lazy, functional iteration over any iterable .
const names = ["Ada","Bob","","Cleo",""];
Iterator.from(names)
.filter(n => n)
.map(n => n.toUpperCase())
.toArray(); // ["ADA","BOB","CLEO"]
2. 🧩 New Set Methods
Overview: Implements set-theory operations:
- Combination:
union,intersection,difference,symmetricDifference - Relationships:
isSubsetOf,isSupersetOf,isDisjointFrom
const A = new Set([1,2,3]), B = new Set([3,4]);
A.union(B); // Set{1,2,3,4}
A.intersection(B); // Set{3}
A.difference(B); // Set{1,2}
A.symmetricDifference(B);// Set{1,2,4}
A.isDisjointFrom(B); // false
3. 📥 JSON Modules with Import Attributes
Overview: Natively import JSON files via with { type: 'json' } .
import config from "./settings.json" with { type: "json" };
console.log(config.appName);
Supports dynamic variants:
const cfg = await import("./settings.json", { with:{type:"json"} });
4. 🧾 RegExp.escape(...) & Inline Regex Flags
Overview:
RegExp.escape(string)safely escapes special regex characters .- Inline, scoped flags like
(?i:…)let you apply modifiers only to parts of the pattern .
const userInput = ".";
const re = new RegExp(RegExp.escape(userInput));
// matches literal dot
/(?i:Love)|(?-i:Day)/.test("love"); // true
/(?i:Love)|(?-i:Day)/.test("day"); // false
5. 🔁 Duplicate Named Capture Groups
Overview: Allows reuse of the same group name in different alternations .
const RE = /(?<name>A+)|(?<name>B+)/v;
RE.exec("AAA").groups.name; // "AAA"
RE.exec("BB").groups.name; // "BB"
6. ⚙️ Promise.try(...)
Overview: Ensures both sync and async errors are normalized to a Promise chain .
Promise.try(() => mayThrowSync())
.then(res => console.log(res))
.catch(err => console.error(err));
Promise.try(() => cachedValue || fetchAsync())
.then(doMore)
.catch(handleError);
7. 🔢 16-Bit Float Support
Overview: Adds half-precision support via:
Float16Array,DataView.prototype.getFloat16()/.setFloat16(),Math.f16round().
const buf = new DataView(new ArrayBuffer(2));
buf.setFloat16(0, Math.PI);
buf.getFloat16(0); // ~3.1406
Math.f16round(1.2345); // rounded half-precision
8. 📏 New DurationFormat Objects (Intl stage)
Overview: A finalized Intl proposal (not core language), enabling human-readable duration formatting . Example:
const df = new Intl.DurationFormat("en", { format: ["hours", "minutes"] });
df.format({ hours: 1, minutes: 45 }); // "1 h 45 min"
✅ Summary Table
| Feature | Benefit |
|---|---|
| Iterator helpers | Lazy, readable iteration |
| Set methods | Native set operations |
| JSON modules | No build tools needed |
| RegExp enhancements | Safe and flexible regex |
| Dup. named groups | Cleaner regex patterns |
| Promise.try | Unified error handling |
| Float16 support | Efficient numeric handling |
| DurationFormat | Human-friendly durations |
Browser support for ECMAScript 2025 is still emerging—most modern browsers are in the process of rolling out these features. Here’s an updated breakdown of where things stand:
🏛️ Core Browsers & Engines
- Chrome (V8 engine): Early support available, with many features (Iterator Helpers, Set methods, JSON modules, RegExp.escape, Promise.try, Float16Array, duplicate named groups, inline regex flags) enabled behind flags or in Canary/Dev builds (Socket).
- Edge (Chromium-based): Follows Chrome’s release cadence; expect similar behind‑flag support in Canary/Dev.
- Firefox: Follows implementation but rollout timing is somewhat slower than V8; most features are in nightly/beta builds.
- Safari/WebKit: Slower to adopt new standards; expect implementation in Technology Preview before mainstream release .
- Deno & Node.js: Node 20+ (with
--harmonyflags or later versions) and Deno support most features already in a stable or experimental capacity .
📊 Feature-by-Feature Landscape
| Feature | Chrome/Edge | Firefox | Safari/WebKit |
|---|---|---|---|
| Iterator Helpers | Canary/Dev w/flag | Nightly/Beta (partial) | Preview only |
| Set union/intersection/etc. | Canary/Dev | Nightly/Beta | Preview |
| JSON Modules / import attrs | Canary/Dev | Nightly/Beta | Preview |
| RegExp.escape & inline flags | Canary/Dev | Nightly/Beta | Preview |
| Duplicate named capture groups | Canary/Dev | Nightly/Beta | Preview |
| Promise.try | Canary/Dev | Nightly/Beta | Preview |
| Float16 support | Canary/Dev | Experimental | Preview |
| Intl.DurationFormat (Intl API) | Behind flags in V8 | Not yet | Preview |
✅ What That Means for You
- Production, today: Practically no browser yet supports ES2025 off the shelf.
-
Modern development: You can test/enjoy these features using:
- Chrome Canary or Dev builds (often with
--enable-featuresflags). - Firefox Nightly.
- Safari Technology Preview.
- Node.js with experimental flags or latest LTS (20+).
- Chrome Canary or Dev builds (often with
- For broad compatibility: Transpilers like Babel (when plugins land) or polyfills like core‑js can safely backport features (github.com, 2ality.com, Medium).
🔧 Recommendations
- Experiment in Chrome Canary, Firefox Nightly, or Node.js 20+ (use flags where needed).
- Use Babel or core‑js for production, if you require these APIs today.
- Monitor status via “Can I Use” and official engine release notes — support is emerging quickly but not universal yet.
Let me know if you’d like guidance for enabling flags, integrating with Babel, or checking specific features!