JS一些常见运算

1.只保留整数:
parseInt();
2.向下取整:
Math.floor();
3.向上取整:
Math.ceil();
4.求余数:

leti=5,j=2;
let y = i%j;

5.求绝对值:
Math.abs();
6.四舍五入:
Math.round();
7.两者中的最小值:
Math.min(a,b);
8.两者中的最大值:
Math.max(a,b);
9.随机数:
Math.random();

猜你喜欢

转载自blog.csdn.net/qq_42314621/article/details/84991582