判断数组

Array.isArray([]); // true

// 尝试用一个类似数组的对象去测试
Array.isArray({
    length: 1,
    "0": 1,
    slice: function() {}
}); // false

//如果你的开发环境不支持ECMAScript5,可以通过Object.prototype.toString()方法来代替。
if (typeof Array.isArray === "undefined") {
    Array.isArray = function(arg) {
        return Object.prototype.toString.call(arg) === "[object Array]";
    };
}
原文地址:https://www.cnblogs.com/qzsonline/p/3039595.html