向两侧整型数中较大的数进行取整
正数时
var num = 1.1;
num = Math.ceil(num);
console.log(num); // 2
负数时
var num = -0.9;
num = Math.ceil(num);
console.log(num); // 0
向两侧整型数中较小的数进行取整
正数时
var num = 1.1;
num = Math.floor(num);
console.log(num); // 1
负数时
var num = -0.9;
num = Math.floor(num);
console.log(num); // -1
var min = Math.min(2,1,4,10,-50);
console.log(min); // - 50
var max = Math.max(2,1,4,10,-50);
console.log(max); // 10
var res = Math.sqrt(4)
console.log(res); // 2
var res1 = Math.abs(-100);
var res2 = Math.abs(100);
console.log(res1,res2); //100, 100