js hack

2018-04-28  本文已影响0人  onbug

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));
上一篇 下一篇

猜你喜欢

热点阅读