typeof 和 instanceof

1 typeof

console.log(typeof 123) // number
console.log(typeof 'abc') // string
console.log(typeof true) // boolean
console.log(typeof undefined) // undefined
console.log(typeof null) // object
console.log(typeof {a: 1}) // object
console.log(typeof [1,2,3]) // object
console.log(typeof function(){ let a = 1}) // function

2 instanceof

判断该对象是谁的实例

console.log([1 ,2 , 3] instanceof Array) // true
上一篇:sql 报错注入tong


下一篇:【Netty报错:】XXXDecoder.decode() did not read anything but decoded a message.