Uint8Array
A typed array whose elements are single bytes, whole numbers from 0 to 255.
In more detail
It is the standard way to hold binary data in JavaScript, in browsers and Node.js alike. Values outside 0 to 255 wrap around, so 256 is stored as 0.
Example
Node.js Buffer extends Uint8Array; its slice() copies bytes while Buffer's old slice() did not.Related terms
- TypedArray — An array-like view, such as Uint8Array, that reads and writes numbers of one fixed type in an ArrayBuffer.
- Buffer — A Node.js object holding a fixed-length run of raw bytes stored outside the V8 heap; more generally, any memory that holds data on its way somewhere.
Taught in
- Buffer Fundamentals: Slab Allocator & V8 Memory — Node.js Internals & Backend Services
- Buffer Encodings: UTF-8, Hex, Base64 & Slicing — Node.js Internals & Backend Services
- Asynchronous File I/O: node:fs/promises & Handles — Node.js Internals & Backend Services