主题

js数学对象常用方法

正文

代码加注释,清晰明了,快来学习吧

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>

<script>
//数学对象
document.write(Math.random()+"<br/>") ;//返回随机数

var a=Math.random();
document.write(a+"<br/>");
document.write(Math.ceil(a*10)) ; //向上取整
document.write(Math.floor(a*10)) ; //向下取整
</script>
</body>
</html>