js去掉小数点后面多余的0

用parseFloat

如:var a=23.8000
alert(parseFloat(a)) //结果:23.8

当然这个也有可能有想不到的结果
document.write(parseFloat("12dream3456.789"));
document.write(parseFloat("dream123456.789"));

结果:
12
NaN

你可能感兴趣的:(js去掉小数点后面多余的0)