« All posts

Every new JavaScript feature worth knowing

A tour of new JavaScript features from ES2025 to ES2027, including Set methods, Iterator Helpers, Promise.try, Import Attributes, and RegExp.escape.

JavaScript is gaining new capabilities at an unusually fast pace across ES2025, ES2026, and early ES2027 proposals. ES2025 brings all seven set-theory methods directly onto Set (union, intersection, difference, and more) without needing array conversions, plus Iterator Helpers, which add lazy, chainable methods like map, filter, and take directly to iterators and generators, making it safe to work with even infinite sequences.

Also part of ES2025, Promise.try converts synchronous throws into rejected promises so a single catch block can handle both sync and async errors, Import Attributes let developers import JSON modules directly and securely without a bundler, and RegExp.escape standardizes safely escaping user input before building dynamic regular expressions.

ES2026 introduces Array.fromAsync for converting async iterables such as streams or paginated API results into arrays, and Error.isError, a realm-agnostic way to check for errors that fixes the classic instanceof Error failure across iframes, now supported in most browsers. Upcoming features like Map.getOrInsert aim to simplify the common check-then-insert pattern on Maps. Collectively, these additions replace common, error-prone workarounds engineers have relied on for years with built-in, standardized, and safer language features.

» SourceHashnode #16