ES6 - Math ceil() 函式



此方法返回大於或等於某個數字的最小整數。

語法

Math.ceil ( x ) ;       

引數

  • X − 代表一個數字

示例

console.log("---Math.ceil()---") 
console.log("Math.ceil(2.2) : "+Math.ceil(2.2)) 
console.log("Math.ceil(-3.8) : "+Math.ceil(-3.8))          

輸出

---Math.ceil()--- 
Math.ceil(2.2) : 3 
Math.ceil(-3.8) : -3         
廣告
© . All rights reserved.