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

后端 未结 3 483
野性不改
野性不改 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:13

    You pass an array as first parameter to min function

    Math.min([1,2])
    

    From MDN

    If at least one of arguments cannot be converted to a number, the result is NaN.

提交回复
热议问题