JavaScript Array isArray() Method

Beginner
⏱️ 8 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Type check

What You’ll Learn

Array.isArray() is the correct way to ask “is this a real array?” It returns true or false, works across iframes, and rejects array-like objects. This tutorial covers syntax, five examples, pitfalls of typeof, and comparisons with instanceof.

01

Syntax

Array.isArray(x)

02

Static

On Array

03

Boolean

true / false

04

Not typeof

object trap

05

Not array-like

Real arrays only

06

ES5

Wide support

Introduction

JavaScript values come in many shapes. Functions that expect an array need a reliable type check before calling map(), filter(), or other array methods.

Array.isArray() is the built-in answer. Do not rely on typeof (arrays are "object") or loose checks like value.length, which confuse array-like objects with real arrays.

Understanding the Array.isArray() Method

Array.isArray(value) returns true only when value is a genuine Array instance created in the current realm. It is a static method—you call it on Array, not on an instance.

It checks one level only. A nested array like [1, [2, 3]] is still an array; inner elements are tested separately if needed.

💡
Beginner Tip

Before looping unknown API data, run Array.isArray(data). If false, wrap a single value in [data] or reject the input with a clear error.

📝 Syntax

General form of the static method:

JavaScript
Array.isArray(value)

Parameters

  • value — any JavaScript value to test.

Return value

  • true if value is an Array.
  • false for all other types (including null, objects, strings, array-likes).

Common patterns

  • Array.isArray(items) — guard before array methods.
  • if (!Array.isArray(x)) throw new TypeError(...) — validation.
  • Array.isArray(x) ? x : [x] — normalize to array.
  • data.filter(Array.isArray) — keep only array elements.

⚡ Quick Reference

GoalCode
Is it an array?Array.isArray(value)
[] resulttrue
{} resultfalse
Array-like objectfalse (use Array.from)
Prefer overtypeof x === "object"

📋 Array.isArray() vs typeof vs instanceof Array

Use isArray for the most reliable array type check in everyday code.

isArray
recommended

Cross-realm safe

typeof
"object"

Not specific

instanceof
Array

Iframe issues

length check
unreliable

Array-like trap

Examples Gallery

Open DevTools Console (F12) or use Try-it labs. Example N maps to ?tryit=N.

📚 Getting Started

Basic true/false type checks.

Example 1 — Array vs Non-Array Values

Compare a real array with a string.

JavaScript
const numbers = [1, 2, 3];
const text = "Hello";

console.log(Array.isArray(numbers));
// true

console.log(Array.isArray(text));
// false
Try It Yourself

How It Works

[1, 2, 3] is an Array instance. Strings are primitives, not arrays (even though strings are iterable).

Example 2 — Array-Like Objects Return false

Objects with length and indices look like arrays but are not.

JavaScript
const arrayLike = { 0: "a", 1: "b", length: 2 };

console.log(Array.isArray(arrayLike));
// false

console.log(Array.isArray(Array.from(arrayLike)));
// true
Try It Yourself

How It Works

Convert array-likes with Array.from() when you need a true array and array methods.

📈 Practical Patterns

typeof pitfalls, validation, and flexible APIs.

Example 3 — Why typeof Is Not Enough

Both arrays and plain objects report "object".

JavaScript
const arr = [1, 2, 3];
const obj = { a: 1 };

console.log(typeof arr);
// "object"

console.log(typeof obj);
// "object"

console.log(Array.isArray(arr));
// true

console.log(Array.isArray(obj));
// false
Try It Yourself

How It Works

typeof tells you the broad category. Array.isArray answers the specific question you usually care about.

Example 4 — Guard a Function That Expects an Array

Validate input before calling array methods.

JavaScript
function sumArray(numbers) {
  if (!Array.isArray(numbers)) {
    throw new TypeError("Input must be an array");
  }
  return numbers.reduce((sum, n) => sum + n, 0);
}

console.log(sumArray([1, 2, 3]));
// 6
Try It Yourself

How It Works

Early validation prevents confusing errors later when reduce or map runs on non-arrays.

Example 5 — Accept an Array or a Single Value

Branch logic based on whether input is already an array.

JavaScript
function processItems(input) {
  if (Array.isArray(input)) {
    input.forEach((item) => console.log("Array item:", item));
  } else {
    console.log("Single value:", input);
  }
}

processItems("Hello");
// Single value: Hello

processItems(["a", "b", "c"]);
// Array item: a
// Array item: b
// Array item: c
Try It Yourself

How It Works

APIs that accept “one or many” items often normalize with Array.isArray first, then wrap or iterate accordingly.

🚀 Common Use Cases

  • Function argument validation — require array parameters.
  • API response parsing — confirm list fields are arrays.
  • Normalize input — wrap single values when not an array.
  • Recursive tree walks — detect nested arrays in mixed data.
  • Library utilities — safe guards before map/filter.
  • JSON handling — arrays vs objects after JSON.parse.

🧠 How Array.isArray() Runs

1

Receive value

Any type: array, object, null, primitive.

Input
2

Internal type tag

Engine checks [[Class]] / species for Array.

Inspect
3

Exclude look-alikes

Array-likes and plain objects return false.

Filter
4

Return boolean

true only for genuine Array instances.

📝 Notes

  • Static method—Array.isArray(x), not x.isArray().
  • null and undefined return false.
  • Nested arrays: outer is array; check inner elements separately if needed.
  • Typed arrays (Uint8Array, etc.) return false—they are not Array instances.
  • Prefer over instanceof for cross-iframe arrays.
  • ES5—excellent support including IE9+.

Browser & Runtime Support

Array.isArray() has been available since ES5 (2009). It is the standard array type check in modern and legacy browsers alike.

Baseline · ES5

Array.isArray()

Supported in Chrome 5+, Firefox 4+, Safari 5+, Edge (all versions), IE 9+, and all modern Node.js versions.

99% Universal support
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
Array.isArray() Excellent

Bottom line: Safe to use everywhere except very old IE8 environments. No polyfill needed for modern projects.

Conclusion

Whenever you need to know if a value is a real array, use Array.isArray(). It is clearer and more reliable than typeof or ad-hoc length checks.

Next, learn Array.of() to create arrays from individual arguments without the quirks of the Array() constructor.

💡 Best Practices

✅ Do

  • Use Array.isArray for all array type checks
  • Validate function args before array methods
  • Normalize single values when APIs accept both forms
  • Convert array-likes with Array.from when needed
  • Throw clear TypeError messages on bad input

❌ Don’t

  • Rely on typeof x === "object" alone
  • Assume anything with .length is an array
  • Use instanceof when cross-realm safety matters
  • Expect typed arrays to pass isArray
  • Confuse strings with character arrays

Key Takeaways

Knowledge Unlocked

Five things to remember about Array.isArray()

The reliable boolean test for real JavaScript arrays.

5
Core concepts
02

Boolean

true / false.

Return
🚫 03

Not typeof

object trap.

Pitfall
📦 04

Not array-like

Use from().

Convert
🌟 05

ES5

IE9+.

Support

❓ Frequently Asked Questions

Array.isArray(value) returns true if value is a real JavaScript Array, and false otherwise. It is the reliable way to check array type.
It is a static method on the Array constructor. Call Array.isArray(x), not x.isArray().
typeof [] returns "object", which is not specific. typeof cannot distinguish arrays from plain objects or other object types.
No. Objects with length and numeric keys (like arguments or NodeList) are not true arrays unless converted with Array.from().
isArray works across iframes and realms. instanceof can fail when arrays come from a different window or frame.
Array.isArray() is ES5. It works in all modern browsers and has been supported in Internet Explorer 9+.
Did you know?

Array.isArray can be passed directly as a callback: [1, "x", []].filter(Array.isArray) returns [[]]—only the nested array survives the filter.

Continue to of()

Learn how to build a new array from a list of arguments without constructor quirks.

of() 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