1. undefined
typeof undefined
// 'undefined'
  1. string
typeof ''
//'string'
  1. number
typeof 1
//'number'
  1. boolean
typeof true
//'boolean'
  1. object
typeof {}
typeof []
typeof null
//'object'
  1. function
typeof function(){}
'function'

总结:

  1. typeof 以全部小写字符串返回类型
  2. 可以区分除了null以外的基本类型
  3. 引用类型只能区分function,不能区分数组与对象