前因:使用typeof判断一个数组得到的是Object
let arr = [];
1、使用 instanceof 判断一个arr是不是Array的实例
let arr = [];
arr instanceof Array // true
2、使用.constructor 判断arr的构造器是不是Array
arr.constructor == Array // true
ps: instanceof 和 constructor 所判读的数组必须当前页面声明,因为array是引用类型存的是地址,每个页面的Array原生对象所引用的地址不一样。
3、Array.isArray(arr); // true
4、使用Object.prototype.toString.call(arr) == ‘[Object, Array]’
ps: 4是3的原理