向上取整数:Math.ceil()
<script type="text/javascript">
document.write(Math.ceil(3.3)+"<br>");
document.write(Math.ceil(-0.1)+"<br>");
document.write(Math.ceil(-9.9)+"<br>");
document.write(Math.ceil(8.9)+"<br>");
</script>
向下取整Math.floor()
<script type="text/javascript">
document.write(Math.floor(3.3))
</script>
四舍五入Math.round()
<script type="text/javascript">
document.write(Math.round(1.6)+ "<br>");
document.write(Math.round(2.5)+ "<br>");
document.write(Math.round(0.49)+ "<br>");
document.write(Math.round(-6.4)+ "<br>");
document.write(Math.round(-6.6));
</script>
随机数Math.random()
random() 方法可返回介于 0 ~ 1(大于或等于 0 但小于 1 )之间的一个随机数。
<script type="text/javascript">
doucument.write(Math.random())
</script>