HTML:
console.log(Math.floor(3.3)); // 向下取整
console.log(Math.ceil(3.3)); // 向上取整
console.log(Math.round(3.3)); // 四舍五入
console.log(Math.round(3.6)); // 四舍五入
console.log(Math.abs(-3)); // 绝对值
console.log(Math.pow(3 , 6)); // pow(底数 , 几次方)
console.log(Math.max(3 , 6 , 8 , 52 , 20)); // 最大值
console.log(Math.min(3 , 6 , 8 , 52 , 20)); // 最小值
// 相关公式
Matn.round(Math.random()*(max - min)) + min
// 判断奇、偶数
Math.isOdd = val => val % 2 !== 0 // 奇数
Math.isEven = val => val % 2 === 0 // 偶数
Math.rnd = (max , min = 0) => {
return Matn.round(Math.random()*(max - min)) + min
}
console.log(Math.rnd(30 , 20));
console.log(Math.isOdd(23)); // true
console.log(Math.isOdd(21)); // true
console.log(Math.isEven(22)); // true