1. Array. IsArray (new) es6

console.log(Array.isArray([])); // true
console.log(Array.isArray({})); // false
Copy the code

2. The prototype __proto__

console.log([].__proto__ === Array.prototype); // true
console.log([].__proto__ === Object.prototype); // false
Copy the code

3. Constructor

console.log([].constructor === Array); // true
console.log([].constructor === Object); // false
Copy the code

4.Object.prototype.toString

console.log(Object.prototype.toString.call([]) === "[object Array]"); // true
console.log(Object.prototype.toString.call({}) === "[object Array]" ); // false
Copy the code

5.instanceof

The instanceof operator is used to determine whether the object pointed to by the constructor’s prototype property is on the prototype chain of another object to be tested

Because Array. __proto__. __proto__ = = = Object. The prototype; (Review the JS prototype chain if you don’t understand)

console.log([] instanceof Array); // true
console.log([] instanceof Object); // true
Copy the code