判断对象是数组的方法

判断对象是数组的方法

  1. Array.isArray(a);
  2. a.constructor.name => "Array"
  3. Object.prototype.toString.call(a)==="[object Array]" 对于所有的基本数据类型都能进行判断包括null undefined也可以
  4. a instanceof Array
  5. a.__proto__===Array.prototype
  6. Array.prototype.isPrototypeOf(a)

猜你喜欢

转载自blog.csdn.net/wdhxs/article/details/112137216