Sometimes you got passed an object in a function, and you need to check if this is an array.

Maybe if it’s an array you perform some operation, and if it’s not an array you perform something else.

How can you determine if an object is an array?

Use the isArray() static method provided by the Array built-in object, introduced in ECMAScript 5:

const list = [1, 2, 3]
Array.isArray(list) //true

Download my free JavaScript book!

But.. wait! Don't stop here.

I created a premium training program that will transform you, quickly, into an excellent JavaScript developer. Practical lessons to learn the 80% of the JavaScript that you need, in 20% of the time!

⬇️ ⬇️ ⬇️

Sign up to the JavaScript Course now!

⬆️ ⬆️ ⬆️