Better Array check with Array.isArray Because arrays are not true array in JavaScript, there is no simple typeof check. No problem! Use the method Array.isArray to check…

JavaScript
var colors=["red","green","blue"];

if(Array.isArray(colors)){
    //colors is an array
}
Source

Also in JavaScript: