1.只保留整数部分(丢弃小数部分)
parseInt(6.123);// 6
2.向下取整
Math.floor(5.123);// 5
let t = 5.1234; ~~t; //5
3.向上取整(有小数,整数就+1)
Math.ceil(5.123); // 6
4.四舍五入(小数部分)
Math.round(5.1234);// 5
Math.round(5.6789);// 6
5.绝对值
Math.abs(-1);// 1
6.返回最大值
Math.max(1,2);// 2
Math.max.apply(null,[1,2,3])// 3
7.返回最小值
Math.min(1,2);// 1
Math.min.apply(null,[1,2,3])// 1
8. 随机数(0-1)
Math.random();// 包含0,不包含1
9.保留小数
let num = 10.123456789
let res = num.toFixed(3)// 10.123
10.判断这个值是否是数字类型
isNaN("abc"): // NaN
isNaN(123): // true