判断一个元素是不是数组

2020-01-31  本文已影响0人  张德瘦嬢嬢

1. 先来试试typeof

2.总结

3.方法

let a=[]

  1. a instanceof Array //true
  2. Array.prototype.isPrototypeOf(a )
  3. Object.prototype.toString.call(a ) //[object Array]
  4. Array.isArray(a)
  5. a.constructor===Array


    代码实现
上一篇 下一篇

猜你喜欢

热点阅读