JavaScript中的Math方法演示




<html>
<head>
<script type="text/javascript">


var  num = 12.4;

alert(Math.round(num));//12

alert(Math.ceil(num));//13

alert(Math.floor(num));//12

alert(Math.random()*10);//产生随机数

alert(parseInt(Math.random()*10));//产生0到9以内的整数


</script>

</head>
<body>
  this is my file 
</body>
</html>




原文地址:https://www.cnblogs.com/cynchanpin/p/6820456.html