MDN documentation on Math.max shows that
If no arguments are given, the result is -Infinity.
And Math.min documentation shows
If no arguments are given, the result is Infinity.
After some thinking, it made sense.
Suppose that you are passing one value to
Math.min(3). The minimum should
3 as it's the sole value pass to the function.
Any value other than Infinity itself (
Infinity === Infinity is
true) should be the minimum, and as
3 is smaller than
Infinity, 3 is returned by
Same thing for
Math.max. If you call
3 is bigger than
3 is returned.
I am not exactly sure if my thought process is correct or not but at least it helps to understand what default values are returned when no argument is passed to
Would anyone let me know if I understood the reason behind the return values?