JS Math.max() 函数

 

Math.max(a,b,...,x,y) -- 返回数个数字中较大的值 

max是maximum的缩写,中文"最大量"的意思

 

 

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

posted @ 2013-10-16 16:15  @敏敏  阅读(3179)  评论(0编辑  收藏  举报