(Math)对象方法
<script type="text/javascript">
// Math 对象的作用:执行普通的算数任务;
// Math 对象提供多种算数值类型和函数。无需在使用这个对象之前对它进行定义
// round() 方法可把一个数字舍入为最接近的整数;
// 语法:Math.round(x) x必须是数字
var a=Math.round(2.4)
document.write(a+"<br>")
// random() 方法可返回介于 0(包含)~ 1(不包含)之间的一个随机数;
document.write(Math.random()+"<br>")
// floor() 方法返回小于等于x的最大整数;(如果传递的参数是一个整数,该值不变)
// 语法:Math.floor(x) x任意数值或表达式
var b=Math.floor(3.8)
document.write(b+"<br>")
document.write("【案例】取得介于 1 到 10 之间的一个随机数"+"<br>")
var c=Math.floor((Math.random()*100)+1)
document.write(c+"<br>")
// max() 方法可返回两个指定的数中带有较大的值的那个数;
// 语法:Math.max(n1,n2,n3,...,nx)
var d=Math.max(2,150,30,50,70)
document.write(d+"<br>")
// min() 方法可返回指定的数字中带有最小值的数字;
// 语法:Math.max(n1,n2,n3,...,nx)
var e=Math.min(2,150,30,50,70)
document.write(e+"<br>")
</script>