如何比较传播参数?

tho*_*olo -4 javascript ecmascript-6

如何将spread参数的值与某个值进行比较?

例如:

var arr = [1, 4, 10];

if(Math.min(...arr) > 1) {
  console.log('Must be greater than 1');
}
Run Code Online (Sandbox Code Playgroud)

给了我undefined.与...自然相同Math.max(...arr).

如果我这样做也会发生:

var val = Math.min(...arr);
Run Code Online (Sandbox Code Playgroud)

然后将变量与某个值进行比较.

为什么?

Mic*_*zko 5

逻辑错了.

var arr = [1, 4, 10];

if(Math.min(...arr) <= 1) {   
  console.log('Must be greater than 1'); 
}
Run Code Online (Sandbox Code Playgroud)