數轉換我有如下的功能:字符串在javascript
payementReceived=data.toJSON().total;
paymentTotal=$("#paymentTotal").html();
console.log(typeof(parseInt(paymentTotal)));
console.log(typeof(parseInt(paymentReceived)));
console.log(parseInt(paymentTotal)-parseInt(paymentReceived));
我得到在控制檯下面
number
number
NaN
如果兩個都是數字,那麼爲什麼它不是我不明白能夠給出適當的減法結果。
'新的Number()',不只是'Number()'。或者--parseInt(xxx,10)' – Oded
請參閱我的編輯 – beNerd
'typeof(NaN)===「number」' – Niklas