const arr = []
// 1. 最简单 ES5+
Array.isArray(arr)

// 2. 兼容性好的方法,也很准确 
Object.prototype.toString.call(arr) === '[object Array]'

// 3. 这个也不错 
arr.constructor.name === 'Array'

// 4. instance  不好用 
console.log(a instanceof Array) // true 
console.log(a instanceof Object) // true 

// 5 找个数组独有的方法 
arr.splice !== undefined


相关文章:

  • 2022-12-23
  • 2021-10-21
  • 2021-11-20
  • 2021-11-30
  • 2021-12-26
  • 2021-11-30
猜你喜欢
  • 2021-11-17
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
相关资源
相似解决方案