Categories
JavaScript Answers

How to check if a variable is an array in JavaScript?

Spread the love

To check if a variable is an array in JavaScript, we use the Array.isArray method.

For instance, we write

const isArray = Array.isArray(value);

to call Array.isArray with value to check if value is an array.

If it is, then true is returned.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *