Check if value is array in JavaScript

👋 FYI, this note is over 6 months old. Some of the content may be out of date.
On this page

instanceof Array Jump to heading

;[] instanceof Array // true
'test' instanceof Array // false

Array.isArray Jump to heading

As of ES5 there is now also:

Array.isArray([]) // true
Array.isArray('test') // false
Array.isArray({}) // false

.constructor === Array Jump to heading

;[].constructor === Array // true
'foo'.constructor === Array // false

From Stack Overflow


← Back home