一,转换为布尔类型:
undefined ==> false
null ==> false
0 ==> false
NaN ==> false
除0和NaN以外的Number类型 ==> true
长度为0的String类型(''和"") ==> false
长度不为0的String类型 ==> true
Object ==> true
二,转换为数字类型:
undefined ==> NaN
null ==> 0
true ==> 1
false ==> 0
数字字符串 ==> 对应的数字值
其它字符串 ==> NaN
Object ==> NaN
三,转换为字符串类型:
undefined ==> "undefined"
null ==> "null"
true ==> "true"
false ==> "false"
Number ==> 对应点字符串,包括"NaN","Infinity","-Infinity"
Object ==> toString()方法的返回值,若没有则为"undefined"
网友评论