JavaScript ES2025 Features: What's New for Modern Web Development

ECMAScript 2025, the 16th edition of the JavaScript language specification, was approved by Ecma International in June 2025. It isn't a flashy release with a single headline feature. Instead it fills long-standing gaps: lazy operations on iterators, real set algebra, safer regular expressions, a cleaner way to start promise chains, native JSON imports, and a half-precision float type. Most of these have now been available in evergreen browsers and current Node.js releases for a while, so this is a good moment to look at what each feature does, where it helps in day-to-day work, and what to watch out for.
This guide covers only what is actually in the ES2025 specification. At the end, we briefly note a few proposals that are often confused with ES2025 but are on a separate track.
Iterator Helpers
Before ES2025, if you had an iterator (from a generator, a Map, a Set, or String.prototype.matchAll) and wanted to map or filter it, you usually converted it to an array first. That works, but it allocates the entire collection up front and can't handle infinite sequences.
ES2025 adds a global Iterator object and helper methods on Iterator.prototype:
- Methods that return a new, lazy iterator:
map,filter,take,drop,flatMap - Methods that consume the iterator and return a value:
reduce,toArray,forEach,some,every,find Iterator.from(), which wraps any iterable or iterator-like object so it gets the helpers
function* naturalNumbers() {
let n = 1;
while (true) yield n++;
}
const firstFiveEvenSquares = naturalNumbers()
.filter((n) => n % 2 === 0)
.map((n) => n * n)
.take(5)
.toArray();
console.log(firstFiveEvenSquares); // [4, 16, 36, 64, 100]
Because the helpers are lazy, the infinite generator above is only pulled as far as needed. Nothing is computed until toArray() asks for values.
Helpers also work on built-in iterators directly:
const prices = new Map([
["basic", 19],
["pro", 49],
["agency", 149],
]);
const premiumPlans = prices
.entries()
.filter(([, price]) => price > 40)
.map(([name]) => name)
.toArray();
console.log(premiumPlans); // ["pro", "agency"]
A few practical notes:
- Iterators are single-use. Once you consume one, it is exhausted. If you need to iterate twice, call
.entries()or the generator again. - These are not array methods. There is no
.length, indexing, orsort(). CalltoArray()when you need array behavior. - Async iterators are not covered. Async iterator helpers are a separate proposal and not part of ES2025.
New Set Methods
Set finally has the operations most developers expected from day one. Each returns a new Set or a boolean, and none of them mutate the original:
| Method | Returns |
|---|---|
a.union(b) |
Elements in either set |
a.intersection(b) |
Elements in both sets |
a.difference(b) |
Elements in a but not in b |
a.symmetricDifference(b) |
Elements in exactly one of the sets |
a.isSubsetOf(b) |
true if every element of a is in b |
a.isSupersetOf(b) |
true if every element of b is in a |
a.isDisjointFrom(b) |
true if the sets share no elements |
const requiredPermissions = new Set(["read", "write"]);
const userPermissions = new Set(["read", "comment"]);
const missing = requiredPermissions.difference(userPermissions);
console.log([...missing]); // ["write"]
console.log(requiredPermissions.isSubsetOf(userPermissions)); // false
const allTags = new Set(["react", "seo"]).union(new Set(["seo", "css"]));
console.log([...allTags]); // ["react", "seo", "css"]
The argument doesn't have to be a Set. It must be "set-like," meaning it has a numeric size property and callable has() and keys() methods. A Map qualifies (its keys are used). A plain array does not, so wrap it: setA.union(new Set(myArray)).
These methods are a nice fit for permission checks, feature flags, tag filtering, and diffing lists of IDs between an API response and local state.
RegExp.escape
Building a regular expression from user input has always been a source of bugs. If someone searches for c++ or $9.99, the special characters break the pattern or change its meaning. Most projects copied a small escaping function from Stack Overflow or pulled in a library.
RegExp.escape() is now built in:
const userQuery = "price: $9.99 (USD)";
const pattern = new RegExp(RegExp.escape(userQuery), "i");
console.log(pattern.test("Listed price: $9.99 (usd)")); // true
The built-in version also handles edge cases that homemade helpers often miss. For example, it escapes a leading digit or letter so the result can be safely concatenated after something like \0 or \c without changing meaning. Use it whenever any part of a pattern comes from data you don't control.
RegExp Pattern Modifiers
Pattern modifiers let you turn the i, m, and s flags on or off for just part of a regular expression, using (?flags:...) and (?-flags:...) groups.
// Case-insensitive only for the protocol, case-sensitive for the path
const re = /^(?i:https?):\/\/example\.com\/Docs$/;
console.log(re.test("HTTPS://example.com/Docs")); // true
console.log(re.test("https://example.com/docs")); // false
// Case-insensitive overall, but one segment must match exactly
const sku = /^(?-i:SKU)-[a-z0-9]+$/i;
console.log(sku.test("SKU-ab12")); // true
console.log(sku.test("sku-ab12")); // false
Only i (ignore case), m (multiline), and s (dotAll) can be modified this way. Flags like g, y, u, and v apply to the whole expression and can't be scoped.
Duplicate Named Capture Groups
Named capture groups ((?<name>...)) have been around since ES2018, but a name could only be used once per pattern. That made it awkward to match the same piece of data in different formats. ES2025 allows the same group name to appear in different alternatives of a pattern:
const datePattern = /(?<year>\d{4})-(?<month>\d{2})|(?<month>\d{2})\/(?<year>\d{4})/;
console.log("2025-06".match(datePattern).groups.year); // "2025"
console.log("06/2025".match(datePattern).groups.year); // "2025"
The restriction is that duplicates must be in separate | branches, so only one of them can ever participate in a given match. Reusing a name within the same branch is still a syntax error.
Promise.try
Promise.try(fn, ...args) calls a function and always returns a promise. If the function returns a value, the promise resolves with it. If it returns a promise, that promise is followed. If it throws synchronously, the promise rejects instead of the error escaping as an exception.
That matters when you call code that might be sync or async, such as a user-supplied callback, a cache lookup that sometimes returns immediately, or a plugin hook:
function loadSettings(source) {
return Promise.try(() => {
if (!source) throw new Error("No settings source provided");
return source.read(); // may return a value or a promise
});
}
loadSettings(null)
.then((settings) => console.log(settings))
.catch((err) => console.error("Failed:", err.message));
// "Failed: No settings source provided"
Older workarounds like Promise.resolve().then(fn) also catch synchronous errors, but they defer the call to a later microtask. Promise.try runs the function immediately and still funnels every outcome into one error path. Extra arguments are passed through to the function, so Promise.try(fetchUser, id) works too.
JSON Modules and Import Attributes
ES2025 standardizes import attributes, the with { ... } clause on import statements, along with the first use of them: JSON modules.
import siteConfig from "./site-config.json" with { type: "json" };
console.log(siteConfig.title);
Dynamic imports take the attributes in an options object:
const { default: translations } = await import("./locales/en.json", {
with: { type: "json" },
});
The type: "json" attribute is not decoration. It tells the host to parse the file as JSON and never execute it as JavaScript, even if the server sends an unexpected MIME type. That closes a security gap where a compromised or misconfigured server could otherwise serve script where you expected data.
Some details worth knowing:
- JSON modules only have a default export.
import { title } from "./config.json" with { type: "json" }is an error. - Bundlers such as Vite, webpack, and esbuild have long allowed importing JSON without attributes. That is a bundler feature. Adding the attribute keeps your code portable to native browser modules and Node.js.
- You may see older code using
assert { type: "json" }. That was an earlier version of the proposal and has been replaced bywith. Update it when you touch those files.
Float16Array and Math.f16round
ES2025 adds a 16-bit (half-precision) floating-point typed array, plus related helpers:
Float16Array, a typed array likeFloat32Arraybut using 2 bytes per elementMath.f16round(x), which rounds a number to the nearest half-precision valueDataView.prototype.getFloat16()andsetFloat16()
const weights = new Float16Array([0.1, 0.5, 1.5]);
console.log(weights.BYTES_PER_ELEMENT); // 2
console.log(weights[0]); // 0.0999755859375 (half precision is lossy)
console.log(Math.f16round(65504)); // 65504 (largest finite float16)
console.log(Math.f16round(70000)); // Infinity
Most web projects won't touch this directly. It matters for graphics and machine learning work: WebGPU supports f16 data, and many model weights are stored in half precision. Being able to read and write that data without manual bit manipulation saves memory and conversion code. Remember that half precision has only about three significant decimal digits, so it's not a substitute for regular numbers in business logic.
Browser and Node.js Support
As of late 2026, every ES2025 feature is supported in the current versions of Chrome, Edge, Firefox, and Safari, and in current Node.js LTS releases. Some features, like the Set methods and iterator helpers, have been available for longer than others, like Float16Array and RegExp.escape, which landed later in some engines.
Before relying on any of them in production:
- Check MDN and caniuse.com for the exact versions that added each feature, and compare them with your analytics or your browserslist targets.
- Know what your build tool does. Transpilers like Babel and TypeScript can down-level syntax, but most of ES2025 is new built-in objects and methods. Those need a polyfill (for example, from core-js) if you support older browsers. Regex modifiers and duplicate named groups are syntax that older engines can't parse at all, so a polyfill won't help there; you'd need a transpiler plugin or a different pattern.
- Set your TypeScript
liboption to include the ES2025 library (oresnexton older compiler versions) so the types for these APIs are available. - Feature-detect in libraries. If you ship code to unknown environments, a check like
typeof Promise.try === "function"is cheap insurance.
If you're curious how modern JavaScript features affect framework choice, our React vs Vue vs Angular comparison looks at the ecosystem side of that decision.
What ES2025 Does Not Include
A number of well-known proposals are often mentioned alongside ES2025 but are not part of it:
- Temporal, the long-awaited replacement for
Date, has been progressing separately and has begun shipping in some browsers. It was not part of ES2025. - Decorators remain a TC39 proposal. TypeScript's decorator support is a compiler feature, not standard JavaScript.
- The pipeline operator (
|>) is still an early-stage proposal. - Records and Tuples were withdrawn from the standards process in 2025; a related "composites" idea is being explored instead.
- Explicit resource management (
usingdeclarations) and async iterator helpers are on their own tracks.
For the current status of any proposal, check the official TC39 proposals repository on GitHub rather than blog posts, since stages change.
Putting It Together
None of these features require you to rewrite anything. The best way to adopt them is gradually:
- Replace hand-rolled regex escaping with
RegExp.escapethe next time you touch a search feature. - Swap array-based set logic (
a.filter(x => b.includes(x))) forintersectionanddifferencewhere you already useSet. - Use iterator helpers when you're processing large or streaming data and don't need an intermediate array.
- Add
with { type: "json" }to JSON imports so your code works the same in the browser, Node.js, and bundlers. - Reach for
Promise.tryat boundaries where sync and async code meet.
Small improvements like these add up to code that is shorter, easier to review, and less dependent on utility libraries, which also helps with bundle size. If performance is your next focus, see our guide to web performance optimization and Core Web Vitals.
Conclusion
ES2025 is a practical, quality-of-life release. Iterator helpers and Set methods make everyday data handling cleaner, the regex additions remove a class of subtle bugs, Promise.try simplifies error handling, and JSON modules give data imports a standard, secure syntax. Check support against your audience, add polyfills where needed, and start using them in new code.
If you're planning a new web application or modernizing an existing JavaScript codebase, our team builds and maintains React and Node.js applications. Get in touch to talk through your project.
DLN Web Studio
Author


