how to check if type is array javascript code example

Example 1: javascript determine array type

var data = ['a', 'b', 'c']
var isArray = Array.isArray(data)
console.log(isArray)

Example 2: javascript check if is array

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

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

Example 3: how to check if something is array javascript

function isArray(value) {
    return Object.prototype.toString.call(value) === "[object Array]";
}

Example 4: javascript check if in array

var extensions = ["image/jpeg","image/png","image/gif"];          
if(extensions.indexOf("myfiletype") === -1){
	alert("Image must be .png, .jpg or .gif");
}