无涯教程-Math.floor(x)函数

130 阅读1分钟

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          

参考链接

www.learnfk.com/es6/es6-mat…