ES6 - Math max() 函式



此方法返回零或更多數字中的最大值。如果未給出引數,結果為 –Infinity。

語法

Math.max(x1,x2,x3..)      

引數

  • X1,x2,x3.. − 代表一系列數字

例項

console.log("---Math.max()---") 
console.log("Math.max(3, 0.5, 0.66) : "+Math.max(3, 0.5, 0.66)) 
console.log("Math.max(-3, 0.5, -0.66) : "+Math.max(-3, 0.5, -0.66))          

輸出

---Math.max()--- 
Math.max(3, 0.5, 0.66) : 3 
Math.max(-3, 0.5, -0.66) : 0.5       
廣告
© . All rights reserved.