Boolean值的转换

可以对任何数据类型的值调用Boolean()函数,而且总会返回一个Boolean值。至于返回的这个值是true还是false,取决于要转换的数据类型及其实际值。

详表:

boolean值的转换
数据类型 转换为true的值 转换为false的值
Boolean true false
String 任何非空字符串 ""(空字符串)
Number 任何非零数字值(包括无穷大) 0和NaN
Object 任何对象 null
Undefined 不适用 undefined
posted @ 2019-09-06 16:50  Syinho  阅读(482)  评论(0编辑  收藏  举报