当前位置: 首页 > 文档资料 > ES6 入门教程 >

Math.min(x1, x2,...)

优质
小牛编辑
116浏览
2023-12-01

此方法返回零或更多数字中的最小值。 如果没有给出参数,则结果为+ Infinity。

语法 (Syntax)

Math.min( x1,x2,… ) ;       

参数 (Parameter)

  • X1,x2,x3 .. - 代表一系列数字

例子 (Example)

console.log("---Math.min()---") 
console.log("Math.min(1, 2) : "+Math.min(1, 2)) 
console.log("Math.min(3, 0.5, 0.66) : "+Math.min(3, 0.5, 0.66)) 
console.log("Math.min(3, 0.5, -0.66) : "+Math.min(3, 0.5, -0.66))          

输出 (Output)

---Math.min()--- 
Math.min(1, 2) : 1 
Math.min(3, 0.5, 0.66) : 0.5 
Math.min(3, 0.5, -0.66) : -0.66