js判断数组

arr = [1,2,3]

1.ES5

Array.isArray(arr); //true

2.instanceof 

arr instanceof Array; // true

3.Object.prototype.toString.call(arr) === '[object Array]' //true

4.constructor

arr.constructor === Array; // true

5.arr.__proto__ === Array.prototype; // true

 

posted @ 2021-12-19 13:05  superil  阅读(24)  评论(0编辑  收藏  举报