总所周知,JS有六大数据类型,分别是Number、String、Boolean、Undefined、Null、Object。
JS的六大数据类型
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

相关文章:

  • 2021-11-19
  • 2022-02-06
  • 2021-08-29
  • 2021-12-05
  • 2021-08-15
猜你喜欢
  • 2021-12-05
  • 2022-02-11
  • 2021-12-05
  • 2022-01-02
  • 2021-12-05
  • 2021-09-21
  • 2021-11-19
相关资源
相似解决方案