Method of judging that the object is an array

Method of judging that the object is an array

  1. Array.isArray(a);
  2. a.constructor.name => "Array"
  3. Object.prototype.toString.call(a)==="[object Array]" It can be judged for all basic data types, including null or undefined
  4. a instanceof Array
  5. a.__proto__===Array.prototype
  6. Array.prototype.isPrototypeOf(a)

Guess you like

Origin blog.csdn.net/wdhxs/article/details/112137216