js 字符串转 数字

<html>
<body>
<script language="javascript">
var a = "0.11";
var b = "0.2801";
var c = "1.002"; 

var sum1 = parseFloat(a)+parseFloat(b)+parseFloat(c);
var sum2 = (parseFloat(a)+parseFloat(b)+parseFloat(c)).toFixed(4)
document.write("a+b+c="+sum1);
document.write("<br/>")
document.write("a+b+c="+sum2)
document.write("<br/>")
var num=new Number(sum2);
document.write("sum2.toFixed(2)= "+num.toFixed(2));
</script>
</body>
</html>
开始做,坚持做,重复做
上一篇:Photoshop为绿树边的美女加上古典中性淡褐色


下一篇:数据库测试DbUnit