判断一个变量是否为数组对象

73 阅读1分钟

代码

var a = [];

console.log(a instanceof Array);

核心:使用instanceof而不是typeof