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.