Number(null);
上面的代码将返回:
Number() Number(0) Number('') Number('0') Number(false) Number(null) Number([]) Number([0])
console.log(Number("")); //0 console.log(Number(null)); //0 console.log(Number(undefined)); //NaN console.log(parseInt("")); //NaN console.log(parseInt(null)); //NaN console.log(parseInt(undefined)); //NaN console.log(null == 0); //false console.log(undefined == 0); //false
Number(0); //0 Number(null); //0 Number([]); //0 Number(""); //0 Number(undefined); //NaN Number(NaN); //NaN Number({}); //NaN
Number(undefined) NaN Number(null) 0 Number(NaN) NaN Number('') 0 Number(false) 0 Number(true) 1 Boolean(undefined) false Boolean(null) false Boolean(NaN) false Boolean('') false Boolean(0) false