Math
is a built-in object that has properties and methods for mathematical purposes.
Math.max() > Math.min() // false
Math.max()
returns -Infinity
when no arguments are provided, i.e. the smallest possible value. By having -Infinity
as the base of comparison, Math.max()
will always return the correct result when only a single value is provided.
Following the same idea, Math.min()
returns Infinity
when no arguments are provided, i.e. the highest possible value.
Therefore, when comparing Math.max() > Math.min()
we are actually comparing -Infinity > Infinity
, which is false
.
Stackoverflow - T.J. Crowder answer ECMAScript® 2015 Language Specification - ToNumber