美文网首页
有关typeof运算符

有关typeof运算符

作者: 木羽木羽女口生 | 来源:发表于2020-12-02 21:26 被阅读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'
    

    相关文章

      网友评论

          本文标题:有关typeof运算符

          本文链接:https://www.haomeiwen.com/subject/dfauwktx.html