有关typeof运算符
2020-12-02 本文已影响0人
木羽木羽女口生
- 识别所有的值类型
- 识别函数
- 判断是否是引用类型(不可再细分)
let a; typeof a // 'undefined'
const str = 'abc'; typeof str //'string'
const n = 100; typeof n //'number'
const b = true; typeof b //'boolean'
const s = Symbol('s'); typeof s //'symbol'
- 能够判断函数
typeof console.log // 'function'
typeof function () {} //'function'
- 能识别饮用类型(不能再继续识别)
typeof null //'object'
typeof ['a','b'] //'object'
typeof{x:100} //'object'