test if array javascript code example
Example 1: if object is array javascript
Array.isArray(object);
Example 2: javascript test if it is an array
if (Array.isArray(object)) {
} else {
}
Array.isArray([1, 2, 3, 4]);
Array.isArray(4);
Example 3: js test if array
if(Array.isArray(myVarToTest)) {
} else {
}
Example 4: in javascript check is is an array or not
Array.isArray(yourItem)
Example 5: 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");
}