- 通过instanceof做判断
- 通过构造函数
- 通过Object.prototype.toString.call()
- 通过Array.isArray()
- 通过原型链来判断
- 通过Array.prototype.isPrototypeOf
- 通过Object.getPrototypeOf
const arr = []
// 通过instanceof做判断
arr instanceof Array // true
// 通过构造函数
arr.constructor === Array // true
// 通过Object.prototype.toString
Object.prototype.toString.call(arr) === '[object Array]' // true
// 通过Array.isArray()
Array.isArray(arr) // true
// 通过原型链来判断
arr.__proto__ === Array.prototype // true
// 通过Array.prototype.isPrototypeOf
Array.prototype.isPrototypeOf(arr) // true
// 通过Object.getPrototypeOf
Object.getPrototypeOf(arr) === Array.prototype // true