• 识别所有值类型
    • 识别函数
    • 识别是否是引用类型(不可再细分)
      1. // 识别所有值类型
      2. let a //undefined typeof a // 'undefined'
      3. const s = 'abc' typeof s // 'string'
      4. const n = 100 typeof n // 'number'
      5. const b = true typeof b // 'boolean'
      6. const s = Symbol('s') typeof s // 'symbol'
      1. // 能判断函数
      2. typeof console.log // 'function'
      3. typeof function () {} // 'function'
      1. // 能识别引用类型(不能再继续识别)
      2. typeof null // 'object'
      3. typeof ['a', 'b'] //'object'
      4. typeof { x: 100 } //'object'