JavaScript Polyfills and Fallbacks
Feature detection, polyfills such as `core-js` and hand-written fallbacks that let modern JavaScript features run in older browsers and runtimes.
Content tagged polyfills
Post:Backwards-Compatible JavaScript: Polyfills and Baseline
Use new JavaScript without breaking older browsers.Write backwards-compatible JavaScript: feature detection, safe core-js polyfills, transpiling vs polyfilling, Baseline and browserslist queries.Snippet:Bytes to Hex and Back with
Uint8Array.fromHex()andtoHex()Convert bytes to hex and back without padStart loops.Encode bytes as hex with ES2026's Uint8Array toHex(), decode with fromHex() and setFromHex(), with SHA-256 digests, colours, error cases and a padStart fallback.Snippet:First N Matches from Any Iterable with
filter()andtake()Get the first N matches and stop reading.Return the first N matches from any iterable with Iterator.from(), filter() and take(), stopping as soon as it has enough, even on infinite sequences.Tutorial:Iterator Helpers: Lazy Pipelines over Any Iterator
Map, filter and take over any iterator, lazily.Use ES2025 iterator helpers (map, filter, take, drop, flatMap, reduce, Iterator.from) to build lazy pipelines over generators, Sets, Maps and infinite sequences.Tutorial:JavaScript Iterator
chunks(),windows(),includes()andjoin()Group, window, search and join any iterator natively.Use JavaScript's new iterator chunks(), windows(), includes() and join() for batching, moving averages and calendar rows, with edge cases and fallbacks.