判断是不是一个数组?

1. instanceof

var a = {
    "name":'suonidfahao',
    "job": 'webEnginner',
}   
var b = [1,2,4,4];
console.log(a instanceof Array); //false
console.log(b instanceof Array); //true

2.Array.isArray(ie9以上支持)

Array.isArray([1, 2, 3]);  // true
Array.isArray({foo: 123}); // false
Array.isArray('foobar');   // false
Array.isArray(undefined);  // false

3.原型链:constructor

var list = [1,2,3,4,5];
console.log(list.constructor === Array); //true
原文地址:https://www.cnblogs.com/duanzhange/p/9298139.html