DEV Community

Discussion on: Math.min returns Infinity?

Collapse
 
kennethlum profile image
Kenneth Lum

I think one reason is

min(a, b, c) = min([], min(a, b, c)) = min(a, min(b, c)) = min(a, b, min(c)) = min(a, b, c, min([]))

that is, you call pull an element out and do a min and the final result is the same. You can pull the nothing out, or you can pull all out. The final form will make min([]) to be Infinity, or else say if it is -Infinity, then the final value would become -Infinity. It is like, with the absence of any value, I don't know what the minimum is and I assume it is still very big.