Math.max() 是内置的 JavaScript 函数,从给定的一组数字中返回最大值。
其语法如下:
Math.max(value1[, value2, ...])
例如,让我们从 1,2 以及 3 中找到最大的数字:
Math.max(1, 2, 3); // => 3
正如预期的那样,函数的返回值为 3。
当调用 Math.max() 时只使用一个数字参数时:
Math.max(1); // => 1
显然,一个数字的最大值是其本身。
但如果调用 Math.max() 时不传递任何参数,那会发生什么?