JavaScript Math.max() 函数
Math.max(a,b,...,x,y) -- 返回数个数字中较大的值
- max是maximum的缩写,中文"最大量"的意思
- 引用网址:http://www.dreamdu.com/javascript/Math.max/
max函数语法
Math.max(a,b,...,x,y);
max函数参数
- a,b,...,x,y -- 为number类型的数字,此值必须大于0
max函数返回值
返回数个数值中较大的值
如果max函数没有给出任何参数,返回-Infinity
如果有NaN或者非数字类型的参数,返回NaN
max函数示例
document.write(Math.max(5,8,6,-5,-6));document.write(Math.max());document.write(Math.max("dreamdu",8));document.write(Math.max(NaN,0));
结果:
8 -Infinity NaN NaN
JavaScript Math.max() 函数示例 -- 可以尝试编辑
延伸阅读
- JavaScript Math.min() 函数 -- 返回数个数字中较小的值