Lodash _.isArrayLike() method

Beginner
⏱️ 6 min read
📚 Updated: May 2026
🎯 3 Code examples
🚀 3 Try-it labs
Lodash

What you’ll learn

  • How _.isArrayLike(value) spots iterable-ish indexed collections.
  • Why strings and legacy arguments qualify while functions do not.
  • How this differs from _.isArray and _.isArrayLikeObject.
  • When invalid length values fail the check.

Prerequisites

Familiarity with length on strings and Arrays, and the difference between Arrays and plain objects.

  • You understand why functions have a length property (arity).
  • You can open Try-it labs in the browser.

Overview

_.isArrayLike powers Lodash’s collection methods when inputs might be Arrays, strings, NodeLists, or shaped POJOs. Use it when you care about indexability plus length—not strict Array typing.

Beyond Arrays

Strings, arguments, typed arrays, and custom list-like objects can qualify.

Functions excluded

Arity length does not make a callable look like a list.

Validated length

NaN, negative, or infinite lengths fail—Lodash mirrors safe length rules.

Syntax

javascript
_.isArrayLike(value)
  • value: any value to test.
  • Returns: true if value looks like an indexed collection with a valid length; otherwise false.
1

Arrays, strings, and classic arguments

Dense Arrays qualify immediately; strings expose UTF-16 length; non-arrow functions still expose arguments with both indices and length.

javascript
import isArrayLike from "lodash/isArrayLike";

isArrayLike([10, 20]);       // true
isArrayLike("hi");           // true

function demo() {
  return isArrayLike(arguments);
}

demo(1, 2, 3);               // true
Try it Yourself
2

Shaped objects versus functions

Plain objects can mimic lists if length is valid. Functions are rejected even though they carry length.

javascript
import isArrayLike from "lodash/isArrayLike";

isArrayLike({ 0: "x", length: 1 }); // true

isArrayLike(function (a, b) {});    // false (arity length ignored)

isArrayLike(null);                  // false
Try it Yourself
3

Typed arrays, Maps, and bad lengths

Typed arrays are collections with element counts. Maps expose size, not length, so they fail. Invalid lengths fail even when indices exist.

javascript
import isArrayLike from "lodash/isArrayLike";

isArrayLike(new Uint8Array(4));     // true

isArrayLike(new Map());             // false

isArrayLike({ 0: 1, length: -1 }); // false
Try it Yourself

📋 _.isArrayLike vs nearby helpers

APITypical match
_.isArrayLike(x)Arrays, strings, arguments, typed arrays, list-shaped objects.
_.isArray(x)True Arrays only.
_.isArrayLikeObject(x)Array-like objects (excludes string primitives).
_.isTypedArray(x)Typed arrays specifically.

Pitfalls to avoid

Unicode

String length vs glyphs

String length counts UTF-16 code units; combining characters and surrogate pairs need separate handling for human-visible counts.

DOM

Need real Arrays?

Array-like DOM collections pass _.isArrayLike but still lack Array prototypes until you call Array.from.

Sparse

Holes and exotic objects

Array-like checks do not guarantee dense data—always validate business rules separately.

❓ FAQ

No. Array.isArray only accepts real Array instances. _.isArrayLike also accepts strings, arguments objects, typed arrays, and plain objects with a valid length.
They expose a non-negative integer length and indexed UTF-16 code units, so many collection helpers can iterate them like dense sequences.
Functions have a length property meaning arity (parameter count). Treating every function as array-like would create surprising matches.
isArrayLikeObject further requires a plain object-like value (excluding primitives such as strings) while still being array-like.

Summary

  • Purpose: detect collection-like values with a sane length.
  • Not: a substitute for Array.isArray when you require Array methods.
  • Next: explore more on Lodash _.isArrayLikeObject().
Did you know?

_.isArrayLike implements Lodash’s shared notion of a finite, non-negative length that behaves like indexed collections—it purposely excludes functions (which also have a length for arity) so arity does not look like a list.

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