r/ProgrammerHumor • • Jun 21 '18

Thanks Brendan for giving us the Javascript

Post image
3.1k Upvotes

302 comments sorted by

View all comments

Show parent comment

4

u/inabahare Jun 21 '18

So you're telling me that functions that determaine the minimum and maximum values of two numbers return something weird when you don't give it any numbers? Really makes you think.

(Also btw, if one or more of the parameters aren't numbers you get NaN, which makes pretty good sense tbh)

0

u/[deleted] Jun 21 '18

[deleted] — view deleted comment

-1

u/[deleted] Jun 21 '18 edited Jun 21 '18

Math.max() has nothing to do with the type system. It's an overloaded function that's clearly described in the docs. It should output negative Infinity (a number) because that's what the function docs say it will do if it is called without a number.

If you're dicking around with type coercion, you've probably made a mistake somewhere.