Course contentsShow
← JavaScript
Lesson 2332 of 2,72348. Working with Binary DataFree lesson

What is an ArrayBuffer?

Understanding ArrayBuffer as a fixed-length raw binary data buffer that holds bytes in memory.

What is an ArrayBuffer?

You'll learn what an ArrayBuffer is and why it's the foundation for working with binary data in JavaScript.

The Core Concept

An ArrayBuffer is a fixed-length container that holds raw binary data in memory. Think of it as a contiguous block of bytes—like a fixed-size box of numbered slots, where each slot holds exactly one byte (a value from 0 to 255).

Unlike regular JavaScript arrays that can hold any type of data and grow dynamically, an ArrayBuffer is:

  • Fixed-length: Once created, its size cannot change
  • Raw: It stores only bytes, with no inherent type or structure
  • Unreadable directly: You can't access its bytes without using a "view" (like Typed Arrays, which you've already learned about)

Why ArrayBuffer Exists

ArrayBuffer serves as the underlying memory container for Typed Arrays. When you create a Typed Array, it often sits on top of an ArrayBuffer, interpreting those raw bytes according to a specific numeric type (like Uint8Array or Float32Array).

A Simple Analogy

Imagine ArrayBuffer as a blank canvas of graph paper with numbered squares. The squares exist and have positions, but you need special glasses (a Typed Array) to interpret what's drawn in them—whether they represent 8-bit integers, 32-bit floats, or something else.

ArrayBuffer itself is just the memory allocation; the interpretation happens through views that you place over it.

Key Takeaway: An ArrayBuffer is a fixed-length container of raw binary data (bytes) that serves as the underlying memory buffer for Typed Arrays and other binary data views.