JavaScript and Modern Web APIs
Posts, tutorials, and snippets on JavaScript — from asynchronous programming fundamentals to modern browser APIs like the Observer family — covering the language and platform features that power interactive web applications.
Content in JavaScript
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.Tutorial:Collecting Async Iterables into Arrays with
Array.fromAsync()Collect any async iterable into an array, one await.Use JavaScript's Array.fromAsync() to collect async generators and iterables into an array: mapping, error handling, sequential vs Promise.all, and browser support.Snippet:Deep Freeze Objects in JavaScript
Recursively lock every object level for true immutabilityLock objects and their children immutably — prevent accidental mutations and enforce deep immutability in strict mode.Snippet:Encapsulation with Closures
Encapsulate private variables using JavaScript closure patterns.Master the functional approach to data encapsulation in JavaScript by leveraging lexical scoping to create immutable private variables.