1.typeof 错误方法
let a = [1,2,3,4]
let type = typeof(a);
console.log(type);
打印结果
原因:对于Object类型和Array类型,typeof检测结果都是Object
2.tostring
let a = [1,2,3,4]
let type = Object.prototype.toString.call(a);
console.log(type);
打印结果
3. instanceof
let a = [1,2,3,4]
let type = a instanceof Array;
console.log(type);
打印结果