Math.floor() 返回小于或等于一个给定数字的最大整数。
Math.floor()
可以理解 Math.floor()为向下取整。
与其相对的是 Math.ceil() ,这个是向上取整。
Math.ceil()
如下面的代码:
Math.floor( 45.95); // 45 Math.floor( 45.05); // 45 Math.floor( 4 ); // 4 Math.floor(-45.05); // -46 Math.floor(-45.95); // -46
上图演示了这个函数的一些小对比。
https://www.ossez.com/t/javascript-math-floor/13731