let arr=[1,2,]
第一种:
if(Array.isArray(arr)){
console.log(‘是‘);
}else{
console.log(‘否‘);
}
第二种:
if(arr instanceof Array){
console.log(‘是‘);
}else{
console.log(‘否‘);
}
第三种:
if(arr.constructor === Array){
console.log(‘是‘)
}else{
console.log(‘否‘)
}
第四种:
if(Object.prototype.toString.call(arr) === ‘[object Array]‘){
console.log(‘是‘);
}else{
console.log(‘否‘);
}
原文:https://www.cnblogs.com/xb130460/p/14780525.html