let type = []
type.constructor = "hello"
复制代码
【不能进一步区分null、数组、对象...】
console.log(typeof type) // object
复制代码
【基本类型需用new声明,且还受继承影响】
console.log(type instanceof Array, type instanceof Object) // true true
复制代码
【指向能够改变】
console.log(type.constructor) // hello
复制代码
console.log(Object.prototype.toString.call(type)) // [object Array]
console.log(Object.prototype.toString.call(type).replace(/\[object\s|\]/g, '')) // Array
复制代码