Check if a value is an array:
Array.isArray([1, 2, 3]) // true
Array.isArray("hello") // false
Array.isArray({ length: 1 }) // false
Don't use typeof for arrays. It returns "object" for both arrays and objects:
typeof [] // "object"
typeof {} // "object"
Array.isArray() is the reliable way to check.