Why does Math.min([1,2]) return NaN?

后端 未结 3 467
野性不改
野性不改 2020-12-30 17:37

I\'ve been debugging this code for about an hour, and it looks like Math.min([1,2]) returns NaN.

var int_array = [1,2]
console.log(         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-30 18:04

    This

    var int_array = [1,2];
    console.log(Math.min.apply(null,int_array));
    

    will work in all actual browsers.

提交回复
热议问题