check if object or array js code example
Example 1: if object is array javascript
Array.isArray(object);
Example 2: js check if array
Array.isArray([1, 2, 3]); // true
Array.isArray('asdf'); // false
Example 3: javascript array contains object
// Works in all browsers
if (array.index(object) !== -1) {
console.log(`my object is in my array`)
}
// ES7 :
if(array.includes(oject)) {
console.log(`my object is in my array`)
}