1.instanceof 判断一个对象是否是由某个类型创建出来的
obj instanceof Array = true //则表示是数组
2.Object.prototype.toString()方法
Object.prototype.toString.call(arr) == [object Array]
3.Array.prototype.isPrototypeOf(obj) //判断指定对象是否存在于另一对象的原型链中
Array.prototype.isPrototypeOf(obj) == true
4.Obejct.getPrototypeOf(arr) == Array.prototype
Object.getPrototypeOf(arr)== Array.prototype //返回对象__proto__指向的原型prototype
5.最简单的方法(存在兼容)
Array.isArray(arr) == true
// 判断是否数组的方法
console.log(Array.isArray(arr))
console.log(arr instanceof Array)
console.log(Array.prototype.isPrototypeOf(arr))
console.log(Object.getPrototypeOf(arr) == Array.prototype)
console.log(Object.prototype.toString.call(arr))