Suppose you want the smallest number returned from Math.max() to
be 0 (just in case negative numbers sneak into the array). You can pass
that argument separately and still use the spread operator for the other
arguments, as follows:
let values = [-25, -50, -75, -100]
console.log(Math.max(...values, 0));
网友评论