let type = []
type.constructor = "hello"
Copy the code

typeof

Cannot further distinguish null, array, object...  console.log(typeoftype) // object
Copy the code

instanceof

Console.log (console.log)type instanceof Array, type instanceof Object) // true true
Copy the code

constructor

Console. log(type.constructor) // helloCopy the code

General: Object. The prototype. ToString. Call ()

console.log(Object.prototype.toString.call(type)) // [object Array]
console.log(Object.prototype.toString.call(type).replace(/\[object\s|\]/g, ' ')) // Array
Copy the code

Judge array

1. [] instanceof Array // true
2. [].constructor === Array // true

3. Object.prototype.toString.call([]) === '[object Array]' // true
4. Array.isArray([]) // true
Copy the code