1、基本数据类型
number 数字
string 字符串 带""的数值
boolean 布尔值 只有true false
undefined 空值
null 0
2.引用数据类型(对象)
Object 对象
Array 数组
Function 函数
转换的情况
转换的情况
字符串 -->布尔值
-除了空串其余全是true
数字-->布尔值
-除了0和NaN其余都是true
null、undefined --> 布尔值
-都是false
对象--->都是true
方式2(隐式类型转换):
-为任意的数据类型转换做俩次非运算,即可转换为布尔值
例如:
var a = "hello";
a = !!a;//true