判断是不是数组

判断是不是数组:

: var e=[ ]

console.log(e.length)
if(typeof e=="object"&&(e.length==0)){
console.log('e is Array')
}//判断e是不是数组

2:console.log(Array.isArray(e))//判断e是不是数组

3:if(Array.isArray(e)){

    console.log('是数组')
}else{
console.log('不是数组')
}//判断e是不是数组

4: console.log(Array.isArray(e)?'是数组':'不是数组')//判断是不是数组

posted @ 2021-12-27 11:00  又等花开风起  阅读(45)  评论(0)    收藏  举报