常见的假值有
值 | 说明 |
var a=false; | 值为假 |
var a =0; | 值为0 |
var a=''; | 值为空 |
var a=10/'abc' | 算式错误 |
var a; | 未赋值变量 |
常见的真值有
值 | 说明 |
var a=true | 值为真 |
var a=1 | 非0数字都是true |
var a='Hello' | 有内容的字符串都是true |
var a=20/5 | 数字运算结果非0 |
var a='true' | 有内容的字符串都是true |
var a='false' | 有内容的字符串都是true |
var a='0' | 有内容的字符串都是true |