Skip to main content

Harshal V. LADHE

JavaScript Typed Arrays

Storing numbers in fixed-size binary form with `Float32Array`, `Uint8Array`, `Float16Array` and the other typed arrays, and reading them with `DataView`.

Content tagged typed-arrays

  • Snippet:Bytes to Hex and Back with Uint8Array.fromHex() and toHex()

    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.
    Published at:
    Categories:JavaScript
    Estimated reading time:5 min read