Lodash _.isArrayBuffer() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.isArrayBuffer(value) identifies true ArrayBuffer instances.
  • Why typed-array views and DataView return false.
  • How this differs from _.isTypedArray and native ArrayBuffer.isView.
  • Practical checks when handling binary payloads in browsers and Node.

Prerequisites

Basic idea that binary APIs use ArrayBuffer plus typed arrays or DataView to read and write bytes.

  • You can run snippets in a modern browser or Node with typed array support.
  • You can open Try-it labs in the browser.

Overview

_.isArrayBuffer answers whether a value is a raw byte container before any typed view is attached. Reach for it when validating inputs from Web Crypto, WebSocket binary frames, fetch arrayBuffer(), or similar APIs.

Raw storage

Matches new ArrayBuffer(n)—including zero-length buffers.

Views are separate

Uint8Array / DataView wrap buffers; they are not buffers themselves.

Not duck typing

Fake objects with byteLength still fail unless they are real instances.

Syntax

javascript
_.isArrayBuffer(value)
  • value: any value to test.
  • Returns: true if value is an ArrayBuffer; otherwise false.
1

Plain ArrayBuffer instances

Any size—including 0 bytes—still constructs an ArrayBuffer, so _.isArrayBuffer stays true.

javascript
import isArrayBuffer from "lodash/isArrayBuffer";

isArrayBuffer(new ArrayBuffer(16)); // true
isArrayBuffer(new ArrayBuffer(0));  // true
Try it Yourself
2

Typed arrays, DataView, and Arrays

Views interpret buffer memory; they are not classified as ArrayBuffers. Ordinary Arrays never qualify.

javascript
import isArrayBuffer from "lodash/isArrayBuffer";

var raw = new ArrayBuffer(8);

isArrayBuffer(new Uint8Array(raw));           // false
isArrayBuffer(new DataView(raw));             // false
isArrayBuffer([]);                            // false
Try it Yourself
3

Same backing memory: buffer vs view

One underlying buffer can power many views; test the buffer when you need ownership of raw storage, and _.isTypedArray (or ArrayBuffer.isView) when any view will do.

javascript
import isArrayBuffer from "lodash/isArrayBuffer";
import isTypedArray from "lodash/isTypedArray";

var backing = new ArrayBuffer(16);

isArrayBuffer(backing);                     // true
isArrayBuffer(new Uint8Array(backing));     // false
isTypedArray(new Uint8Array(backing));      // true
Try it Yourself

📋 _.isArrayBuffer vs related checks

APITypical match
_.isArrayBuffer(x)ArrayBuffer instances.
_.isTypedArray(x)Uint8Array, Float64Array, etc.
ArrayBuffer.isView(x)Any typed array or DataView.
_.isArray(x)Ordinary JavaScript arrays only.

Pitfalls to avoid

Views

Assuming typed arrays are buffers

Grab .buffer from a typed array only when you know offsets align with what your API expects.

Shared

SharedArrayBuffer

Not treated as a classic ArrayBuffer; gate features carefully where workers need shared memory.

Node

Buffer objects

Node’s Buffer is Uint8Array-based but distinct from user-created ArrayBuffer checks—use Buffer helpers when integrating native APIs.

❓ FAQ

No. Typed arrays are views over an ArrayBuffer, not ArrayBuffers themselves. Use _.isTypedArray or native ArrayBuffer.isView for view detection.
Shared buffers are a distinct builtin type; _.isArrayBuffer does not classify SharedArrayBuffer as an ordinary ArrayBuffer. Use typeof checks or feature guards when you need shared memory.
No. Lodash checks actual ArrayBuffer instances, not duck-typed shapes.
In Node, Buffer is different from ArrayBuffer (unless you are bridging typed arrays). Check Buffer separately when integrating native Node buffers.

Summary

  • Purpose: detect raw ArrayBuffer instances.
  • Exclude: typed-array views, DataView, ordinary Arrays.
  • Next: explore more on Lodash _.isArrayLike().
Did you know?

An ArrayBuffer holds fixed-length raw bytes; Uint8Array, Float32Array, and DataView are separate constructors that view a buffer. Lodash follows that split—only the naked buffer passes _.isArrayBuffer.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful