Math.max
Math.max
功能
最大值。返回所有参数中的最大值。
语法
Math.max(value1, value2, ...)
参数
| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
| value1, value2, ... | Number | 是 | 无 | 待比较数字,至少传入 1 个。 |
返回值
| 类型 | 说明 |
|---|---|
| Int/Float | 返回所有参数中的最大值。整数结果返回 Int,非整数或非有限结果返回 Float。 |
示例
result = Math.max(3, 1, 2) // 输出:3 print result
注意事项
- 不传参数会报错:Math.max() 至少需要 1 个数字参数。