jQuery jQuery.isArray() Method

Beginner
⏱️ 10 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Array test

What You’ll Learn

The jQuery.isArray() utility returns true when a value is a genuine JavaScript array — not merely array-like. This tutorial covers syntax, five worked examples, comparisons with Array.isArray() and $.type(), and guard patterns before calling jQuery array utilities.

01

Syntax

$.isArray(obj)

02

Boolean

true / false

03

[] yes

True arrays

04

{} no

Plain objects

05

Not-like

NodeList false

06

Guard

Before $.grep

Introduction

Before you filter, merge, or search with jQuery array utilities, you need to know whether the input is actually an array. The expression typeof [] returns "object", which also matches plain objects, dates, and null — so it cannot reliably answer the question.

jQuery provides jQuery.isArray() (also written $.isArray()) as a focused boolean test. It returns true only for real Array instances and false for everything else — including array-like objects that have a length property but lack array methods.

Understanding the jQuery.isArray() Method

jQuery.isArray(obj) is equivalent to jQuery.type(obj) === "array". Internally jQuery inspects the value’s internal class tag — the same mechanism that makes $.type([]) return "array" instead of "object".

Use it in plugin code, AJAX handlers, and validation logic whenever you need a clear yes/no before calling $.grep(), $.merge(), or native methods like .map() and .filter().

💡
Beginner Tip

Array-like is not array. $.isArray(document.querySelectorAll("p")) is false — convert with $.makeArray() first, then the result passes $.isArray().

📝 Syntax

General form of jQuery.isArray:

jQuery
jQuery.isArray( obj )
// or
$.isArray( obj )

Parameters

  • obj — any JavaScript value to test.

Return value

  • true if obj is a true JavaScript Array.
  • false for all other values — objects, primitives, array-like collections, and null.

Minimal workflow

jQuery
if ($.isArray(items)) {
  var filtered = $.grep(items, function (n) { return n > 0; });
}

⚡ Quick Reference

Value$.isArray()
[]true
[1, 2, 3]true
new Array()true
{}false
"text"false
nullfalse
NodeListfalse (array-like)
jQuery collectionfalse (array-like)

📋 $.isArray vs Array.isArray vs $.type

Three ways to detect arrays — pick the one that fits your codebase.

$.isArray
true / false

jQuery boolean; arrays only

Array.isArray
true / false

Native ES5; same true-array test

$.type
"array"

String when you need many types

typeof
"object"

Unreliable for arrays

Examples Gallery

Each example uses $.isArray(). Open DevTools or use the Try-it links to run them interactively.

📚 Getting Started

The official jQuery API demo — arrays pass, objects fail.

Example 1 — Arrays Return true, Objects Return false

The simplest check from the jQuery documentation.

jQuery
console.log($.isArray([]));  // true
console.log($.isArray({}));  // false
Try It Yourself

How It Works

An empty array [] is still a true Array instance. A plain object {} has no array prototype, so the test correctly returns false.

📈 Practical Patterns

Array-like traps, utility guards, comparisons, and option validation.

Example 2 — Array-Like Objects Are Not Arrays

NodeLists and jQuery collections look like arrays but fail $.isArray().

jQuery
var nodeList = document.querySelectorAll("p");
var $items   = $("p");
var realArr  = $.makeArray(nodeList);

console.log($.isArray(nodeList)); // false
console.log($.isArray($items));   // false
console.log($.isArray(realArr)); // true — after makeArray
Try It Yourself

How It Works

Array-like objects expose .length and numeric indexes but lack the Array prototype. jQuery utilities like $.grep often accept array-like input anyway — but $.isArray strictly tests for true arrays only.

Example 3 — Guard Before $.grep()

Normalize unknown input: convert if needed, or grep when already an array.

jQuery
function filterPositive(input) {
  var arr = $.isArray(input) ? input : $.makeArray(input);
  return $.grep(arr, function (n) { return n > 0; });
}

console.log(filterPositive([0, 1, 2]));           // [1, 2]
console.log(filterPositive({ 0: 0, 1: 3, length: 2 })); // [3]
Try It Yourself

How It Works

When input might be array-like, branch on $.isArray: use the value directly when it is already a true array, otherwise convert with $.makeArray before filtering.

Example 4 — Compare $.isArray, Array.isArray, and $.type

All three agree on true arrays; only typeof misleads.

jQuery
var data = [1, 2, 3];

console.log($.isArray(data));        // true
console.log(Array.isArray(data));    // true
console.log($.type(data) === "array"); // true
console.log(typeof data);            // "object"
Try It Yourself

How It Works

In jQuery 3+, $.isArray uses Array.isArray internally when available. Both are safe array tests. Use $.type when your code must also distinguish dates, functions, and null.

Example 5 — Validate a Plugin’s items Option

Reject or wrap non-array configuration before iterating.

jQuery
function initList(options) {
  options = options || {};
  var items = options.items;

  if (!$.isArray(items)) {
    console.warn("items must be an array — got " + $.type(items));
    items = [];
  }

  return items.length;
}

console.log(initList({ items: ["a", "b"] })); // 2
console.log(initList({ items: "oops" }));     // 0 (warned)
Try It Yourself

How It Works

Plugin authors combine $.isArray for the boolean gate and $.type in error messages so developers see exactly what was passed. Fall back to a safe default instead of throwing when possible.

🚀 Common Use Cases

  • Plugin option validation — ensure list options are true arrays before iteration.
  • AJAX response checks — confirm JSON parsed to an array before mapping results.
  • Utility preconditions — guard calls to $.grep, $.merge, and $.inArray.
  • Array-like conversion — branch to $.makeArray when isArray is false.
  • Defensive coding — avoid calling native .map() on non-arrays.
  • Legacy jQuery projects — consistent checks before ES5 Array.isArray was universal.

🧠 How jQuery.isArray() Decides

1

Receive value

Any JavaScript value is passed to $.isArray(obj).

Input
2

Inspect class

jQuery checks whether the internal tag is [object Array] (or delegates to Array.isArray in jQuery 3+).

Test
3

Exclude look-alikes

Array-like objects with length but no array prototype return false.

Strict
4

Return boolean

true for genuine arrays; false for everything else.

📝 Notes

  • Available since jQuery 1.3.
  • Equivalent to jQuery.type(obj) === "array".
  • jQuery 3+ uses native Array.isArray when the browser supports it.
  • Does not mutate the value — read-only test.
  • Sparse arrays and empty arrays still return true.
  • Related: $.makeArray() to convert array-like values; $.type() for full type strings.

Browser Support

jQuery.isArray() has been part of jQuery since jQuery 1.3+. It works wherever jQuery runs — all modern browsers and legacy IE when paired with a supported jQuery build.

jQuery 1.3+

jQuery jQuery.isArray()

Supported in jQuery 1.x, 2.x, and 3.x. jQuery 3 delegates to native Array.isArray when available.

100% With jQuery loaded
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
jQuery.isArray() Universal

Bottom line: Safe in any project that already includes jQuery. Without jQuery, use Array.isArray() directly in ES5+ environments.

Conclusion

The jQuery.isArray() utility answers one question with a boolean: is this value a true JavaScript array? It avoids the typeof trap, ignores array-like impostors, and pairs naturally with $.makeArray() when conversion is needed.

Use it to guard plugin options and jQuery array utilities; then explore jQuery.isEmptyObject() for blank plain-object checks.

💡 Best Practices

✅ Do

  • Check with $.isArray() before native .map() / .filter()
  • Fall back to $.makeArray() for array-like input
  • Combine with $.type() in helpful error messages
  • Use Array.isArray() in jQuery-free modern modules
  • Default to empty arrays when validation fails in plugins

❌ Don’t

  • Use typeof x === "object" to detect arrays
  • Assume NodeLists or jQuery objects pass isArray
  • Confuse array-like with array — test explicitly
  • Call instanceof Array across iframes without care
  • Skip validation on user-supplied list options

Key Takeaways

Knowledge Unlocked

Five things to remember about jQuery.isArray()

Test for true arrays the jQuery way.

5
Core concepts
🗃 02

[] only

True arrays

Scope
🚫 03

Not-like

NodeList false

Trap
🔄 04

makeArray

Convert fix

Pair
📄 05

vs type

Bool vs str

Compare

❓ Frequently Asked Questions

jQuery.isArray(obj) returns true when obj is a true JavaScript Array, and false otherwise. It is the boolean shortcut for jQuery.type(obj) === "array".
No. NodeLists, HTMLCollections, the arguments object, and jQuery DOM collections are array-like but not arrays — $.isArray() returns false for them. Use $.makeArray() first if you need array behavior.
Both test for true arrays. In jQuery 3+, isArray delegates to Array.isArray when available. Use $.isArray in jQuery code for consistency; use Array.isArray in jQuery-free modern code.
typeof [] returns "object", which is useless for distinguishing arrays from plain objects. $.isArray() and Array.isArray() correctly identify real arrays.
jQuery.type(value) returns the string "array" for arrays. jQuery.isArray(value) returns true for the same values. Use isArray when you only need true/false; use type when branching on many kinds of values.
Before passing data to $.grep(), $.merge(), or $.inArray() when the input comes from user code or APIs — confirm it is a true array, or convert array-like input with $.makeArray() first.
Did you know?

Before ES5 standardized Array.isArray(), jQuery plugins relied on $.isArray() for portable array detection across IE6–8. The method still matters in jQuery codebases today — and in jQuery 3 it simply forwards to the native API when available, giving you both consistency and performance.

Continue to jQuery.isEmptyObject()

Test whether a plain object has any enumerable properties.

isEmptyObject() 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.

6 people found this page helpful