JS的数据类型

93 阅读1分钟

JS的7种数据类型

number 数字
string 字符串
bool 布尔
symbol 符号
undefinednullobject 对象

数组、函数、日期 它们都属于object

JS五个假值,其他都是真的

  • undefined null 0 NaN ''

8.png

类型转换

number => string
String(n),或者n+''

string = > number
Number(s)
parselnt(s) / parseFloat(s)
s-0

x => bool
Boolean(x)
!!x

x => string
String(x)
x.toString()