JavaScript学习——Math对象

min()和max()

var max=Math.max(3,54,32,16);
alert(max);//54
var min=Math.min(3,54,32,16);
alert(min);//3

ceil(),floor(),round()

alert(Math.ceil(25.9));//26
alert(Math.ceil(25.5));//26
alert(Math.ceil(25.1));//26

alert(Math.round(25.9));//26
alert(Math.round(25.5));//26
alert(Math.round(25.1));//25

alert(Math.floor(25.9));//25
alert(Math.floor(25.5));//25
alert(Math.floor(25.1));//25

random()

var num=Math.floor(Math.random()*10+1);
原文地址:https://www.cnblogs.com/pilee/p/3446562.html