Syntax - Tasty Web Development Treats
Syntax - Tasty Web Development Treats

6 or so New Approved and Proposed JavaScript APIs

In this episode of Syntax, Wes and Scott talk about new approved and proposed JavaScript API changes including Promise.withResolvers, .at(), Immutable Array Methods, Array.fromAsync, and more. Show Notes 00:10 Welcome 04:55 What are we going to cover? 06:10 Promise.withResolvers 09:40 .at() You prob

Featured Speakers

Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers Host

Topics Discussed

Episode Summary

Executive Summary: Syntax hosts Scott and Wes discuss six current and emerging JavaScript APIs, explaining what problems each solves and whether they’re ready to use. They cover Promise.withResolvers, Array.at, immutable array methods, Array.fromAsync, array grouping, observable events, plus a bonus look at import attributes and pattern matching, tying each to practical developer ergonomics and browser support.

Main Topics: Promise.withResolvers and deferred promises: Stage 3 API that returns a promise plus its resolve/reject functions, making it easier to hand control of promise completion to external callbacks or event handlers. Array.at and safer indexing: Now broadly available in browsers and runtimes; supports positive and negative indexing for arrays and strings, improving ergonomics and avoiding manual length math. Immutable array methods: New non-mutating counterparts like toReversed, toSorted, toSpliced, and with help developers avoid accidental state mutation and simplify immutable workflows. Array.fromAsync and async iterables: Converts async iterables/generators into arrays by consuming items sequentially, useful when the final length is unknown or the source can grow while iterating. Array grouping APIs: Proposed grouping helpers that collect array items into buckets by a computed key, reducing boilerplate reduce logic for common categorization tasks. Observable events and composable event flows: An early proposal for turning event handling into observable-style pipelines with filtering, mapping, and take-until semantics, especially useful for drag and other multi-event interactions. Import attributes and other bonus proposals: Import attributes standardize importing JSON and potentially other non-JS assets; the episode also briefly touches on map in-place updates, decorators, and pattern matching.

Key Arguments: Promise.withResolvers solves a real ergonomics problem by separating promise creation from the code that resolves or rejects it, especially in stream and callback-heavy flows. Array.at is cleaner than bracket syntax for access and uniquely supports negative indexing without risking backward-compatibility issues. Immutable array methods reduce bugs caused by in-place mutation and make React/state-style workflows much easier to reason about. Array.fromAsync matters when the source is asynchronous and potentially unbounded, because you cannot assume the total number of items ahead of time. Grouping APIs eliminate repetitive reduce boilerplate and make common data transformations more readable. Observable events could make complex event lifecycles declarative and composable in a way that is easier to manage than nested addEventListener logic. Import attributes are valuable because they standardize what bundlers like Vite already do for JSON and other assets, making imports part of the module system rather than build tooling hacks.

Data Points: Promise proposal stage: Stage 3 - Promise.withResolvers is described as a near-finished proposal likely to ship soon. Array.at status: Supported in all browsers, Node, and Deno - The hosts note Array.at is already broadly available. Immutable array method examples: toReversed, toSorted, toSpliced, with - These are described as non-mutating counterparts to reverse, sort, splice, and item replacement. Array.fromAsync proposal stage: Stage 2 - Mentioned as already shipped in Firefox and Safari while still progressing through the standards process. Array grouping proposal stage: Stage 2 - Presented as an emerging built-in alternative to Lodash-style grouping. Observable events status: Not clearly assigned a stage in the episode - Discussed as a fresh proposal surfaced via social media rather than a settled standard. Import attributes stage: Previously called import assertions - Used to standardize imports such as JSON with type metadata. Size of a custom grouping helper: 293 bytes - Wes mentions a tiny utility library helper that currently fills this role for him. Coupon code: tasty treat - Sentry sponsor offer mentioned for two months free. Vacation destination: Anguilla - Scott discusses his recent trip and driving experience on the left side of the road.

Pivotal Quotes: "Promise.withResolvers will return the promise, but it will also return the resolve and reject methods for you so that you can, you sort of have these like portable little switches to your or portable triggers to your promise" — Scott: Explaining the core benefit of the proposal. "the negative access one is massive" — Scott: Discussing why Array.at matters, especially for getting the last element without manual length arithmetic. "Observables turn event handling, filtering, and termination into explicit, declarative flow that's easier to understand and compose than today's imperative version" — Scott: Summarizing the appeal of observable events.

Implications: Several of these APIs reduce boilerplate, mutation bugs, and bundler-specific workarounds. Listeners should expect JavaScript to become more ergonomic for async control, immutable state, and event composition as proposals mature.

🔓 Sign Up for Unlimited Episode Search

About Syntax - Tasty Web Development Treats

View all episodes from Syntax - Tasty Web Development Treats