Your product could be here, in front of thousands of JavaScript developers. Sponsor this spot →
JavaScript Quiz

Why is Math.max() < Math.min() true?

Do you know what will be the output of this code?

JavaScript
console.log(Math.max() < Math.min());
Show answer and explanation

When called without arguments, Math.max() returns -Infinity and Math.min() returns Infinity.

That’s because each function starts from the value that any other number will beat. Math.max starts at -Infinity and keeps the largest argument it sees, and Math.min starts at Infinity and keeps the smallest. With no arguments, the starting value is returned:

Math.max() // => -Infinity
Math.min() // => Infinity
-Infinity < Infinity
=> true
Take the full quiz Next question →

More Numbers questions

  1. Why is typeof NaN "number" in JavaScript?
  2. Why does 018 - 015 equal 5 in JavaScript?
  3. Why is 0.1 + 0.2 == 0.3 false in JavaScript?
  4. What is -7 % 3 in JavaScript?
  5. Why does indexOf not find NaN but includes does?

Related topics