Uint8Array
Unsigned 8-bit integers from 0 to 255.
Typed arrays let JavaScript work with binary data using fixed-size numeric views.
const bytes = new Uint8Array([72, 105]); console.log(bytes.length); console.log(new TextDecoder().decode(bytes));
JSON & Structured Data
Regular arrays can hold any JavaScript values. Typed arrays hold numbers in a specific binary format such as Uint8, Int16 or Float32.
Typed arrays are used for files, graphics, audio, networking, cryptography and binary protocols.
A typed array is a view over an ArrayBuffer. Multiple views can look at the same underlying bytes in different ways.
Unsigned 8-bit integers from 0 to 255.
Signed 16-bit integers.
32-bit floating point values.
Typed arrays view bytes stored in an ArrayBuffer.
Examples
const encoder = new TextEncoder();
const bytes = encoder.encode("Ready");
console.log(bytes instanceof Uint8Array);
const bytes = [72, 105]; // This is not a binary buffer and has no fixed numeric type.
Code patterns
These patterns focus on the data boundaries you will use constantly: JSON, URLs, forms, files, fetch objects and binary buffers.
Uint8Array is common for raw bytes.
const bytes = new Uint8Array([72, 105]);
TextDecoder turns bytes into a string.
const text = new TextDecoder().decode(bytes);
TextEncoder turns a string into bytes.
const bytes = new TextEncoder().encode("Hi");
Two typed arrays can view the same buffer.
const buffer = new ArrayBuffer(4); const bytes = new Uint8Array(buffer); const words = new Uint16Array(buffer);
Rules that matter
Structured data becomes reliable when every boundary is explicit: text to object, form to values, URL to parameters, response to JSON and bytes to meaning.
They store numbers in fixed-size formats.
Uint8, Int16 and Float32 mean different ranges and precision.
The ArrayBuffer stores the bytes. The typed array views them.
Do not hand-roll UTF-8 conversion.
Uint8Array values stay in the 0-255 byte range.
Normal arrays are better for general data.
Production thinking
Typed arrays are how JavaScript speaks binary data without leaving the language.
Binary processing should still produce readable status and errors for users.
Production binary code should document byte order, numeric type and expected size.
Typed arrays do not affect crawled text directly, but generated media and files still need descriptive labels.
Live code lab
The preview runs inside an isolated iframe. The JavaScript is placed inside the HTML editor for now, so every example stays together and remains easy to understand.
Mini assignment
Practice assignment
Try it yourself
Self-check
Structured data is safe only when you know where it came from, what shape it has and what conversion happened before use.