Underscore.js _.isTypedArray() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if object is a TypedArray (official Underscore docs). Views like Int8Array and Uint8Array pass; regular arrays, ArrayBuffer, and DataView do not. Stable helper (Underscore 1.11+) — not deprecated.

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

Syntax

Call _.isTypedArray. Start with this line.

Underscore
_.isTypedArray(object)
CallWhat it does
_.isTypedArray(object)Primary signature.
_.isTypedArray(...)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
_.isTypedArray(object)

Parameters

ParameterDescription
objectRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official: new Int8Array(8)

The docs check a real TypedArray with eight signed bytes.

Underscore
_.isTypedArray(new Int8Array(8));
// → true
Try It Yourself

How It Works

  1. Create. new Int8Array(8) allocates eight signed 8-bit slots.
  2. Type check. Underscore recognizes it as a TypedArray → true.
  3. Official example. This is the sample from the Underscore documentation.
  4. Read-only. Nothing is mutated; you only get a boolean.

Example 2 — Other TypedArray Kinds

Any TypedArray constructor passes — element size does not matter.

Underscore
_.isTypedArray(new Uint8Array(4));
// → true

_.isTypedArray(new Float32Array(2));
// → true

_.isTypedArray(new Uint16Array([1, 2, 3]));
// → true
Try It Yourself

How It Works

  1. Uint8. Unsigned bytes — still a TypedArray.
  2. Float32. Floating-point view — still a TypedArray.
  3. From values. Constructing from an array of numbers does not change the type.
  4. Rule. Kind and length vary; the TypedArray family still passes.

Example 3 — Array, Buffer, and DataView Fail

Related binary types are not TypedArrays — use the matching helper.

Underscore
_.isTypedArray([1, 2, 3]);                 // → false
_.isTypedArray(new ArrayBuffer(8));        // → false
_.isTypedArray(new DataView(new ArrayBuffer(8))); // → false

_.isArray([1, 2, 3]);                      // → true
_.isArrayBuffer(new ArrayBuffer(8));       // → true
_.isDataView(new DataView(new ArrayBuffer(8)));   // → true
Try It Yourself

How It Works

  1. Normal array. [] is not a binary view → use _.isArray.
  2. Buffer. ArrayBuffer holds raw bytes → use _.isArrayBuffer.
  3. DataView. A view, but not typed-element → use _.isDataView.
  4. Pick the helper. Match the check to the binary type you actually have.

Example 4 — Guard Before Reading Bytes

Only sum indexed values when the input is a TypedArray.

Underscore
function sumBytes(value) {
  if (!_.isTypedArray(value)) {
    return 0;
  }
  var total = 0;
  for (var i = 0; i < value.length; i++) {
    total += value[i];
  }
  return total;
}

sumBytes(new Uint8Array([1, 2, 3])); // → 6
sumBytes([1, 2, 3]);                 // → 0
sumBytes(new ArrayBuffer(3));        // → 0
Try It Yourself

How It Works

  1. Guard first. Skip non-TypedArrays so you never treat a buffer like an indexable view.
  2. TypedArray path. Sum 1 + 2 + 3 from the Uint8Array → 6.
  3. Fail closed. Normal arrays and buffers return 0.
  4. Pattern. Type-check → then read indexed elements.

Browser & Runtime Support

_.isTypedArray ships with Underscore.js 1.11+. It needs a runtime that provides TypedArrays (modern browsers and current Node). Works via CDN or bundle with npm install underscore.

✓ Stable · Underscore 1.11+

_.isTypedArray()

Available in [email protected]+ (UMD / ESM). Requires TypedArray support (widely available since ES2015-era engines). Fine on evergreen browsers and current Node LTS when Underscore is loaded.

98% Modern TypedArray runtimes
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
_.isTypedArray Underscore 1.11+

Bottom line: Safe for modern apps once Underscore 1.11+ is loaded. Not a native browser API by itself — load Underscore first. Prefer a pinned CDN version (e.g. [email protected]).

Frequently Asked Questions

_.isTypedArray(object) returns true only when the value is a TypedArray — for example new Int8Array(8) or new Uint8Array(4). Regular arrays, ArrayBuffers, DataView, strings, and plain objects return false.
_.isTypedArray(new Int8Array(8)) returns true. The docs pick a real TypedArray on purpose — that is the type the helper looks for.
No. [] is a JavaScript Array of values. A TypedArray is a fixed-type binary view such as Int8Array or Float32Array. Use _.isArray for normal arrays.
No. ArrayBuffer is the raw byte storage. DataView is a different kind of view. Use _.isArrayBuffer or _.isDataView for those types.
typeof new Int8Array(8) is "object", so typeof is too broad. Underscore uses ArrayBuffer.isView when available (excluding DataView) or an internal TypedArray tag check.
No. It is a stable Underscore helper added in version 1.11.0 with _.isArrayBuffer and _.isDataView. Load Underscore 1.11+ and call _.isTypedArray(value).

Next: Object methods hub

Browse keys, extend, pick, type checks, and the rest of Underscore’s object helpers.

Object methods →

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