let names=['Jhon','David','Mark'];
console.log(Array.isArray(names));
// true
let user={id:1,name:'David'};
console.log(Array.isArray(user));
// false
let age 18;
console.log(Array.isArray(age));
// false
Array.isArray([1, 2, 3]); // true
Array.isArray({toto: 123}); // false
Array.isArray("tototruc"); // false
Array.isArray(undefined); // false
if(Array.isArray(colors)){
//colors is an array
}
// all following calls return true
Array.isArray([]);
Array.isArray([1]);
Array.isArray(new Array());
Array.isArray(new Array('a', 'b', 'c', 'd'));
Array.isArray(new Array(3));
// Little known fact: Array.prototype itself is an array:
Array.isArray(Array.prototype);
// all following calls return false
Array.isArray();
Array.isArray({});
Array.isArray(null);
Array.isArray(undefined);
Array.isArray(17);
Array.isArray('Array');
Array.isArray(true);
Array.isArray(false);
Array.isArray(new Uint8Array(32));
Array.isArray({ __proto__: Array.prototype });
if(Object.prototype.toString.call(someVar) === '[object Array]') {
alert('Array!');
}