①obj instanceof Array / Object
②Array.prototype.isPrototypeOf(obj)
③Object.prototype.toString.call(obj)
④Array.isArray(obj)
实例:
//typeof() 【原始类型:可分辨;引用类型:object】 console.log(typeof([])); //object console.log(typeof({})); //object //①obj instanceof 构造函数名/类型名 console.log([] instanceof Array); //true console.log({} instanceof Array); //false //②Array.prototype.isPrototypeof(obj) console.log(Array.prototype.isPrototypeOf([])); //true console.log(Array.prototype.isPrototypeOf({})); //false //③Object.prototype.toString.call(obj) console.log(Object.prototype.toString.call([])); //[object Array] console.log(Object.prototype.toString.call({})); //[object Object] //④ES5: Array.isArray(obj) 【兼容性】 console.log(Array.isArray([])); //true console.log(Array.isArray({})); //false