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

 

 

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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-07-18
  • 2021-07-05
  • 2021-11-08
猜你喜欢
  • 2021-07-15
  • 2022-02-23
  • 2022-12-23
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
相关资源
相似解决方案