Math.isOdd = val => val%2 !==0
Math.isEven = val => val%2 ===0
Math.rnd = (max,min=0)=>{
return Math.round(Math.random()*(max-min)+min)
}
console.log(Math.floor(3.1));//向下取整
console.log(Math.ceil(3.1));//向上取整
console.log(Math.round(3.1));//四舍五入
console.log(Math.round(3.5));//四舍五入
console.log(Math.abs(-3));//绝对值
console.log(Math.pow(2,3));//数字的3次方
console.log(Math.max(2,3,20,50));//取最大值
console.log(Math.min(2,3,20,50));//取最小值
console.log(Math.isEven(22));//偶数
console.log(Math.isOdd(23));//奇数
console.log(Math.isOdd(21));//奇数
function rnd(max,min=0){
return Math.round(Math.random()*(max-min))+min
}
console.log(Math.rnd(30,20));//20-30之间的随机数