总所周知,JS有六大数据类型,分别是Number、String、Boolean、Undefined、Null、Object。
1、Object对象包含Function、Array和Date等引用类型。
2、Number数字类型包含整数和浮点数两种。
3、String即字符串含有length属性计算长度,可以通过String()、toString()实现字符串转换。
4、boolean类型只有true和fasle两个值。
5、Undefined类型只有一个值,即undefined值。
6、null类型被看做空对象指针。
typeof操作符
由于js中的变量是松散类型,所以他提供了一种检测当前变量属性的方法,typeof关键字。
typeof 123 //Number
typeof ‘abc’ //String
typeof true //Boolean
typeof undefined //Undefined
typeof null //Object
typeof { } //Object
typeof [ ] //Object
typeof console.log() //Function