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
複製代碼