Math.floor() 返回小于或等于一个给定数字的最大整数。
可以理解 Math.floor()为向下取整。
与其相对的是 Math.ceil() ,这个是向上取整。
如下面的代码:
代码语言:javascript复制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


