floor()方法对 x 进行下舍入。
Math.floor(x) - 语法
Math.floor( x ) ;
- x - 代表数字
Math.floor(x) - 示例
console.log("---Math.floor()---") console.log("Math.floor(2.8) : "+Math.floor(2.8)) console.log("Math.floor(-3.2) : "+Math.floor(-3.2))
运行上面代码输出
---Math.floor()--- Math.floor(2.8) : 2 Math.floor(-3.2) : -4