js中typeof用来判断当前变量的类型,其返回值共有七种:
number, boolean, string, undefined, object, function,symbol.
eg. number
typeof 10
typeof NaN // NaN在JavaScript中代表的是特殊非数字值,它本身是一个数字类型。
typeof Infinity
eg. boolean
typeof true
typeof false
eg. string
typeof 'a'
eg. undefined
typeof undefined
typeof a // a是为声明的变量
eg. object 对象 数组 null 都返回object
typeof null
typeof {}
eg. function
typeof Array
typeof Data
eg. symbol
typeof Symbol() // ES6提供的新的类型