Playgrounds

Change the code, watch it react

31 runnable demos. Edit the HTML, CSS or JavaScript and it re-runs in your browser.

Array.fromAsync — interactive playground
Playground

Array.fromAsync — interactive playground

A for-await loop that pushes into an array, or the `await Promise.all([...asyncIterable])` workaround that silently fails — `Array.fromAsync` replaces both with a single awaited call. It's Baseline 2024.

Open the playground →
content-visibility: auto — skip off-screen rendering
Playground

content-visibility: auto — skip off-screen rendering

Browsers lay out and paint the entire page on load, including the 80% below the fold. `content-visibility: auto` tells the browser to skip that work for off-screen elements — and it's Baseline 2024.

Open the playground →
CORS request simulator — interactive playground
Playground

CORS request simulator — interactive playground

A complete guide to CORS: the same-origin policy, preflight requests, and Access-Control-Allow-Origin headers — with worked examples and a cheat sheet.

Open the playground →
scheduler.yield() — stop freezing the main thread
Playground

scheduler.yield() — stop freezing the main thread

Long synchronous tasks block the main thread and make your interface unresponsive. `scheduler.yield()` is the native way to hand control back to the browser mid-task so it can paint, handle input, and resume your work exactly where it left off.

Open the playground →
light-dark() — one rule, both themes
Playground

light-dark() — one rule, both themes

Every `@media (prefers-color-scheme: dark)` block duplicates your color definitions. `light-dark()` lets you write both values on the same line, in the same rule, with no separate block and no build step. Baseline 2024.

Open the playground →
URL.parse() vs new URL() — safe URL parsing
Playground

URL.parse() vs new URL() — safe URL parsing

Validating an untrusted URL before parsing it used to mean a try/catch wrapper or a regex. `URL.canParse()` checks validity without constructing. `URL.parse()` parses and returns null on failure. Both are Baseline 2024 — no wrapper needed.

Open the playground →
@scope — native CSS style scoping
Playground

@scope — native CSS style scoping

BEM, CSS Modules, and scoped component styles all exist because CSS leaks — a rule written for one component can silently affect another. `@scope` gives the cascade a lower boundary so styles stay where you put them, natively, with no build step.

Open the playground →
Eager arrays vs lazy iterator helpers
Playground

Eager arrays vs lazy iterator helpers

Every `.map()` and `.filter()` on an array creates a new intermediate array. Iterator helpers — built into JavaScript since 2024 — give you the same pipeline but evaluate one element at a time, with no wasted allocations.

Open the playground →
color-mix() — native CSS color blending
Playground

color-mix() — native CSS color blending

Sass's `darken()`, `lighten()`, and `mix()` functions solved real problems CSS couldn't handle for decades. `color-mix()` is the native answer, and it ships in every modern browser with no build step required.

Open the playground →
text-wrap: balance & pretty — end headline orphans
Playground

text-wrap: balance & pretty — end headline orphans

The classic fix for a headline that breaks awkwardly — a manual `<br>`, a `&shy;`, or a max-width tweak — exists because CSS had no way to distribute line breaks evenly. `text-wrap: balance` and `text-wrap: pretty` are the native answers.

Open the playground →
ResizeObserver — interactive playground
Playground

ResizeObserver — interactive playground

A `window` resize listener only fires when the viewport changes. ResizeObserver fires whenever the element's own box changes — from content loading, parent reflow, container queries, or anything else.

Open the playground →
@starting-style — interactive playground
Playground

@starting-style — interactive playground

Before `@starting-style`, the moment an element entered the DOM was invisible to CSS — transitions had no 'before' state to interpolate from. The at-rule gives you one, natively, with no JavaScript required.

Open the playground →
using / explicit resource management — interactive playground
Playground

using / explicit resource management — interactive playground

The Explicit Resource Management proposal adds a `using` declaration that calls cleanup the moment a scope exits — normal return, early return, or throw. No more try/finally boilerplate for timers, event listeners, connections, or any other resource you need to release.

Open the playground →
Set algebra — interactive playground
Playground

Set algebra — interactive playground

Set has always been missing its obvious operations. ES2025 adds `.union()`, `.intersection()`, `.difference()`, `.symmetricDifference()`, and three boolean predicates — native methods that used to require four lines of spread syntax each.

Open the playground →
Promise.withResolvers() — interactive playground
Playground

Promise.withResolvers() — interactive playground

The 'deferred promise' pattern — storing resolve and reject outside the constructor so you can call them later — is a daily JavaScript idiom that's always felt awkward. ES2024 added a one-liner for it.

Open the playground →
Error.cause — interactive playground
Playground

Error.cause — interactive playground

Every time you catch an error and rethrow a new one without forwarding the original, you lose the stack trace, the error type, and everything useful about what actually went wrong. ES2022 added `Error.cause` to fix exactly this.

Open the playground →
TypeScript Generics: any vs &lt;T&gt;
Playground

TypeScript Generics: any vs &lt;T&gt;

Learn TypeScript generics from the ground up — generic functions, constraints, defaults, and classes — with worked examples and a copy-paste cheat sheet.

Open the playground →
IntersectionObserver — interactive playground
Playground

IntersectionObserver — interactive playground

Detecting whether an element is in the viewport by listening to scroll events runs an expensive layout calculation on every frame. `IntersectionObserver` is the browser-native alternative — it fires only when visibility changes, off the main thread, with no scroll handler involved.

Open the playground →
CSS Anchor Positioning — position a tooltip with zero JS
Playground

CSS Anchor Positioning — position a tooltip with zero JS

CSS Anchor Positioning is Baseline 2026 — it lets any element declare itself an anchor and any floating element position relative to it in pure CSS. No JavaScript, no layout math, no ResizeObserver wiring.

Open the playground →
Logical properties — flip the layout to RTL, watch it hold
Playground

Logical properties — flip the layout to RTL, watch it hold

Physical CSS properties like `margin-left` and `padding-right` break silently when a layout needs to support right-to-left languages. Logical properties replace the physical axis with a writing-mode-aware model — one codebase, every direction.

Open the playground →
subgrid — snap the card footers onto one line
Playground

subgrid — snap the card footers onto one line

CSS Grid controls your outer container, but its children can't participate in the same tracks. `subgrid` closes that gap — nested elements align to the parent grid's rows and columns without padding hacks, fixed heights, or JavaScript measurements.

Open the playground →
sort() vs toSorted() — watch the reference
Playground

sort() vs toSorted() — watch the reference

The classic array methods — sort, reverse, splice — mutate the original array, silently breaking React state updates and surprising anyone who forgot to spread first. ES2023 added four immutable counterparts: toSorted, toReversed, toSpliced, and with.

Open the playground →
Object.groupBy — group an array in one line
Playground

Object.groupBy — group an array in one line

Grouping an array by a key is one of the most common data transforms in frontend code. You've been wiring it by hand with `reduce` for years. `Object.groupBy` is the native version — no helper, no library, no ceremony.

Open the playground →
the JavaScript event loop
Playground

the JavaScript event loop

Learn how the JavaScript event loop really works — call stack, microtasks, and macrotasks — with worked examples, edge cases, and a cheat sheet.

Open the playground →
Promise.all vs allSettled vs any vs race — a live lab
Playground

Promise.all vs allSettled vs any vs race — a live lab

`Promise.all` fails the moment any one request fails. `allSettled`, `any`, and `race` each solve a different concurrency problem — dashboard partial results, CDN failover, and timeouts. Here's the taxonomy.

Open the playground →
The native Popover API — two attributes, no JS
Playground

The native Popover API — two attributes, no JS

Custom dropdowns, tooltips, and menus built with stacked divs and click-outside listeners — the Popover API landed in every browser in 2024, and the baseline version is two HTML attributes.

Open the playground →
satisfies — validate without widening
Playground

satisfies — validate without widening

Type annotations widen your object types and erase the precise values TypeScript inferred. The `satisfies` operator validates against a type without changing what TypeScript keeps — you get the check without the widening.

Open the playground →
structuredClone vs spread vs JSON — deep clone playground
Playground

structuredClone vs spread vs JSON — deep clone playground

JSON.parse(JSON.stringify(obj)) silently corrupts Dates, Maps, Sets, and undefined values. structuredClone is the native replacement — no library, no import, no surprises.

Open the playground →
Native CSS nesting — interactive playground
Playground

Native CSS nesting — interactive playground

CSS has supported nesting natively since 2023 — pseudo-classes, pseudo-elements, and @media queries nested inside the rules they belong to. No compiler required.

Open the playground →
@property — give a CSS variable a type
Playground

@property — give a CSS variable a type

CSS custom properties are string substitution — the browser doesn't know a number from a color. Register one with @property and it gains a real type, an initial value, and the ability to animate.

Open the playground →
CSS scroll-driven animations
Playground

CSS scroll-driven animations

Reading progress bars, reveal-on-scroll effects, parallax — you've been writing these in JavaScript. CSS scroll-driven animations bind them directly to scroll position, off the main thread, in a handful of lines.

Open the playground →