Underscore.js _.isArray() Method

Beginner
5 min read
Updated: Nov 2026
4 examples
Object

Definition

Returns true if object is an Array (official Underscore docs). Array-like values such as arguments and NodeLists 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 _.isArray. Start with this line.

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

Parameters

ParameterDescription
objectRequired. Value to test

Return Value

Return ValueDescription
*true or false

Underscore.js Examples

Example 1 — Official Docs

The docs show arguments failing and a real array passing.

Underscore
(function () {
  return _.isArray(arguments);
})();
// → false

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

How It Works

  1. Call a function. JS builds an Arguments object (even with no params).
  2. Test it. _.isArray(arguments) → false.
  3. Test a literal. [1, 2, 3] is a real Array → true.
  4. Takeaway. Looks-like-a-list is not enough — the type must be Array.

Example 2 — Why typeof Is Wrong

Empty arrays are still arrays. typeof cannot tell them from objects.

Underscore
console.log(_.isArray([]), typeof []);   // true "object"
console.log(_.isArray({}), typeof {});   // false "object"
console.log(_.isArray("moe"));           // false
Try It Yourself

How It Works

  1. Empty array. [] is still an Array → true.
  2. Plain object. {} is not an Array → false.
  3. typeof trap. Both print "object", so typeof alone fails.
  4. Strings. "moe" is not an Array → false.

Example 3 — Array-like Objects

Numeric keys and length do not make an Array. Convert first.

Underscore
var alike = { 0: "a", 1: "b", length: 2 };

console.log(_.isArray(alike));              // false
console.log(_.isArray(_.toArray(alike)));   // true
Try It Yourself

How It Works

  1. Fake list. Indexes and length look array-like, but the type is Object.
  2. Check fails. _.isArray(alike) → false.
  3. Convert. _.toArray builds a real Array.
  4. Check passes. The copy is a true Array → true.

Example 4 — NodeList Is Not an Array

querySelectorAll returns a NodeList. Convert before calling .map.

Underscore
var list = document.querySelectorAll("body");

console.log(_.isArray(list));              // false
console.log(_.isArray(_.toArray(list)));   // true
Try It Yourself

How It Works

  1. DOM query. querySelectorAll returns a NodeList, not an Array.
  2. Type check. _.isArray(list) → false.
  3. Convert. _.toArray(list) copies the nodes into a real Array.
  4. Then use array APIs. Call .map / .filter on the copy.

Browser & Runtime Support

_.isArray ships with Underscore.js (1.x). It runs anywhere Underscore runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install underscore.

✓ Stable · Underscore 1.x

_.isArray()

Available in [email protected] (UMD / ESM). In modern engines it delegates to native Array.isArray; older engines fall back to a toString tag check.

100% With Underscore 1.x
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
_.isArray Underscore 1.x+

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

Frequently Asked Questions

_.isArray(object) returns true only when the value is a real Array — created as [], new Array(), or similar. Having numeric keys and a length property is not enough.
The arguments object is array-like: it has a length and indexed values, but it is not created by the Array constructor. The official docs show (function(){ return _.isArray(arguments); })() is false. Use _.toArray(arguments) if you need a real array.
In modern engines, yes. Underscore delegates to the native Array.isArray when it exists, and falls back to an Object.prototype.toString tag check in very old environments.
No. querySelectorAll returns a NodeList. jQuery returns a collection. Both look list-like, but _.isArray is false. Convert with _.toArray or Array.from if you need array methods like .map.
In JavaScript, arrays are objects. typeof cannot tell an array from {}. Use _.isArray (or Array.isArray) when you need that distinction.
No. It is a stable Underscore 1.x helper. Prefer it (or Array.isArray) over typeof whenever you need a real Array check.

Next: _.isObject()

Test whether a value is object-like — functions and plain objects included.

_.isObject() 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