Underscore.js _.isArrayBuffer() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if object is an ArrayBuffer (official Underscore docs). Arrays, TypedArrays, and DataView return false.

Pass the required arguments shown below. Underscore object helpers usually return a new value — check whether the source object is mutated.

Syntax

Call _.isArrayBuffer. Start with this line.

Underscore
_.isArrayBuffer(object)
CallWhat it does
_.isArrayBuffer(object)Primary signature.
_.isArrayBuffer(...)Call with the arguments your case needs.

Load Underscore with import _ from "underscore" (or the UMD CDN build) so these helpers are available as _.

Library declarations
Underscore
_.isArrayBuffer(object)

Parameters

ParameterDescription
objectRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official Docs

The docs show a real ArrayBuffer passing and a regular array failing.

Underscore
_.isArrayBuffer(new ArrayBuffer(8));
// → true

_.isArrayBuffer([]);
// → false
Try It Yourself

How It Works

  1. Create a buffer. new ArrayBuffer(8) allocates 8 raw bytes.
  2. Test it. _.isArrayBuffer(…) → true.
  3. Test an array. [] holds JS values, not binary bytes → false.
  4. Takeaway. The helper checks the type, not “list-like” shape.

Example 2 — Look-alikes Fail

null, strings, and arrays fail. A real buffer passes.

Underscore
var buffer = new ArrayBuffer(16);

console.log(_.isArrayBuffer(null));    // false
console.log(_.isArrayBuffer(""));      // false
console.log(_.isArrayBuffer([]));      // false
console.log(_.isArrayBuffer(buffer));  // true
Try It Yourself

How It Works

  1. null / string / array. None is an ArrayBuffer → all false.
  2. Real buffer. new ArrayBuffer(16) → true.
  3. Safe call. Passing null does not throw.
  4. Rule. Only the ArrayBuffer constructor’s result passes.

Example 3 — Views vs Buffer

TypedArray and DataView sit on a buffer. Only the buffer itself passes.

Underscore
var buffer = new ArrayBuffer(8);
var bytes = new Uint8Array(buffer);
var view = new DataView(buffer);

console.log(_.isArrayBuffer(buffer));        // true
console.log(_.isArrayBuffer(bytes));         // false
console.log(_.isArrayBuffer(view));          // false
console.log(_.isArrayBuffer(bytes.buffer));  // true
Try It Yourself

How It Works

  1. Buffer first. Raw memory passes the check.
  2. TypedArray. Uint8Array is a view → use _.isTypedArray.
  3. DataView. Also a view → use _.isDataView.
  4. Back to buffer. bytes.buffer is the same ArrayBuffer → true again.

Example 4 — byteLength vs Type

Empty and 8-byte buffers both pass. Size is a separate property.

Underscore
var empty = new ArrayBuffer(0);
var eight = new ArrayBuffer(8);

console.log(_.isArrayBuffer(empty));  // true
console.log(_.isArrayBuffer(eight));  // true
console.log(empty.byteLength, eight.byteLength); // 0 8
Try It Yourself

How It Works

  1. Type check. Both values are ArrayBuffers → both true.
  2. Size check. Read byteLength when you care about capacity.
  3. Empty is valid. Zero bytes still counts as an ArrayBuffer.
  4. Rule. Do not mix “is a buffer?” with “how big is it?”.

Browser & Runtime Support

_.isArrayBuffer ships with Underscore.js 1.11.0+. It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore. ArrayBuffer itself is a standard ES2015 feature.

✓ Stable · Underscore 1.11+

_.isArrayBuffer()

Available in [email protected]+ (UMD / ESM). Works in evergreen browsers and current Node LTS when Underscore is loaded and ArrayBuffer exists.

100% With Underscore 1.11+
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
_.isArrayBuffer Underscore 1.11+

Bottom line: Safe for production once Underscore 1.11+ is on the page or in your bundle. Not a native browser API — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.isArrayBuffer(object) returns true only when the value is an ArrayBuffer — for example new ArrayBuffer(8). Regular arrays, TypedArrays, DataView, strings, numbers, null, and plain objects return false.
_.isArrayBuffer(new ArrayBuffer(8)) returns true. The docs pick a real ArrayBuffer on purpose: that is the type the helper looks for.
No. [] is a JavaScript array of values. An ArrayBuffer is a raw block of binary bytes. Underscore treats an array as not an ArrayBuffer.
No. A Uint8Array or DataView is a view onto a buffer, not the buffer itself. Use view.buffer if you need the underlying ArrayBuffer, then _.isArrayBuffer will return true.
typeof new ArrayBuffer(8) is "object", so typeof is too broad. instanceof ArrayBuffer usually agrees in the same window. Underscore uses the [object ArrayBuffer] tag, which is more consistent across iframes than instanceof.
No. It is a stable Underscore helper added in version 1.11.0, along with _.isDataView and _.isTypedArray. Use it to decide whether a value is the raw buffer before you wrap it in a view.

Next: _.isDataView()

Detect DataView wrappers — the multi-byte view that sits on an ArrayBuffer.

_.isDataView() tutorial →

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.

10 people found this page helpful