日期:2014-05-16 浏览次数:20273 次
var bb = "35.23ace23"; document.write(Number(bb)); //NaN document.write(parseFloat(bb)); //35.23 document.write(parseFloat(Number(bb))); //NaN
var aa = 2.3362; document.write(aa.toFixed(1)); // 2.3 document.write(aa.toFixed(2)); // 2.34 document.write(aa.toPrecision(2)); // 2.3 document.write(aa.toPrecision(3)); // 2.34 document.write(Math.round(-4.60)); // -5 document.write(Math.round(aa * 10) / 10); // 2.3 document.write(Math.round(aa * 100) / 100); // 2.34