typeof 2; //number
typeof "2"; //string
parseInt("2");//2
typeof Infinity; //number
parseInt(Infinity);//NaN
typeof NaN; //number
parseInt(NaN);//NaN
是否有其他Number
其parseInt值爲NaN
的元素?如果是的話,單/形容他們請JavaScript中有parseInt值= NaN的數字
更新:什麼無厘頭的JavaScript是isNaN(NaN)
回報true
而typeof NaN
回報number
對字符串
[讓我們來談談Javascript](https://www.destroyallsoftware.com/talks/wat) –
總是有助於閱讀[** documentation **](https://developer.mozilla.org/en- US/docs/Web/JavaScript/Reference/Global_Objects/parseInt):*「要解析的值,如果字符串不是字符串,則將其轉換爲1,忽略字符串中的空白字符」* –