JavaScript
中只有6个假值:
-
undefined
-
null
-
NaN
-
0
-
''
(empty string) -
false
//下面这些值哪些是假值?
0;
new Number(0);
("");
(" ");
new Boolean(false);
undefined;
//答案:0, '', undefined
JavaScript
中只有6个假值:undefined
null
NaN
0
''
(empty string)false
//下面这些值哪些是假值?
0;
new Number(0);
("");
(" ");
new Boolean(false);
undefined;
//答案:0, '', undefined