Example:
let a = 1
let b = 'ss'
let c
let d = null
let e = true
let f = {
}
let g = function () {
}
console.log(typeof a)
console.log(typeof b)
console.log(typeof c)
console.log(typeof d)
console.log(typeof e)
console.log(typeof f)
console.log(typeof g)
Result:
The function of instanceof is whether the __proto__ of the preceding variable and the prototype of the following variable are crossed. Refer to the following figure for details.
Example:
function Foo() {
}
let a = new Foo()
console.log(a instanceof Object)
Result: In
this example, a.__proto__ and Object.prototype are the same, so return true