ES6 - Math floor() 函数



x 的地板:小于或等于 x 的最大整数。

语法

Math.floor( x ) ;      

参数

  • 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          
广告
© . All rights reserved.