Rog Locket 3/4 stack developer and web-scale hacker. I code exclusively #serverless backends.

Comparison of the top Array verification utilities on npm

2 min read 590


A few weeks ago, I was working on my side project, array-length, a highly performant new JavaScript library for calculating the number of elements in a JavaScript array, when I faced an interesting challenge. I needed a way of validating that a users’ input was truly an array, and not some other type of object that might break my algorithm’s complex control flow.

As is often the case with any sufficiently lucrative business opportunity, there are a variety of solutions on the market that aim to solve this problem. They range from focused, best-of-breed libraries ideal for startups and mid-market customers, to highly scalable, enterprise-grade solutions that offer a wide range of functionality.

Given the myriad of options, I was surprised to find that little literature exists to help a buyer make an informed decision. Perhaps the array verification market is too new to be covered by the likes of Gartner and Forrester, my typical sources for reviews on JavaScript libraries.

Instead, I decided to spend a few weeks surveying the landscape and writing up my findings. Below you’ll find my summary of the top three solutions across a variety of metrics including performance, scalability, maintainability, interoperability, debuggability, readability, and web-scaleability.


isarray is an excellent npm package that can accurately detect whether its given argument is or is not an array. While the README states that, “isarray is for older browsers and deprecated Node.js versions.” I found that it works quite well with new browsers and the latest version of Node.

It take a single argument and returns a boolean of whether or not the given object is indeed an Array.


var isArray = require('isarray');
console.log(isArray([])); // => true
console.log(isArray({})); // => false


  • concise, highly-expressive syntax
  • works well with MongoDB
  • Excellent ROI (only 2 month pay back period)


  • No 3rd party plugin ecosystem
  • 3 open GitHub issues


is-array takes a wildly different approach to JavaScript array verification, opting for a hyphen instead of an empty string between is and array in the package title. It offers significantly improved readability over the compound title of isarray while still providing the majority of the functionality expected by the discerning engineer.

It take a single argument and returns a boolean of whether or not the given object is indeed an Array.

We made a custom demo for .
No really. Click here to check it out.


var isArray = require('is-array');
console.log(isArray([])); // => true
console.log(isArray({})); // => false


  • It’s cool because it’s less popular


  • longer name means larger source code (slower Git pushes, less free hard drive space, etc)
  • Permissive MIT license means a large company could Embrace, Extend and Extinguish it


A last resort, suitable only in cases when 3rd party modules are not allowed (enterprise security constraints, use on a dessert island, etc), Array.isArray() is a built-in JavaScript method that was introduced along with the ES5 standard.

It take a single argument and returns a boolean of whether or not the given object is indeed an Array.


console.log(Array.isArray([])); // => true
console.log(Array.isArray({})); // => false


  • At least 95% accurate


  • Not on npm
  • Not supported in Opera 4
  • Will throw an error if you try to import it with webpack


Rog Locket is a developer and humorist who writes a weekly satirical column for the LogRocket blog. He is entirely fictional.

You come here a lot! We hope you enjoy the LogRocket blog. Could you fill out a survey about what you want us to write about?

    Which of these topics are you most interested in?
    ReactVueAngularNew frameworks
    Do you spend a lot of time reproducing errors in your apps?
    Which, if any, do you think would help you reproduce errors more effectively?
    A solution to see exactly what a user did to trigger an errorProactive monitoring which automatically surfaces issuesHaving a support team triage issues more efficiently
    Thanks! Interested to hear how LogRocket can improve your bug fixing processes? Leave your email:

    : Full visibility into your web apps

    LogRocket is a frontend application monitoring solution that lets you replay problems as if they happened in your own browser. Instead of guessing why errors happen, or asking users for screenshots and log dumps, LogRocket lets you replay the session to quickly understand what went wrong. It works perfectly with any app, regardless of framework, and has plugins to log additional context from Redux, Vuex, and @ngrx/store.

    In addition to logging Redux actions and state, LogRocket records console logs, JavaScript errors, stacktraces, network requests/responses with headers + bodies, browser metadata, and custom logs. It also instruments the DOM to record the HTML and CSS on the page, recreating pixel-perfect videos of even the most complex single-page apps.

    Rog Locket 3/4 stack developer and web-scale hacker. I code exclusively #serverless backends.

    Leave a Reply