Some functions do not behave as expected. Sadly, most programmers accept them.
TL;DR: Don't trust max() and min() functions. Just ignore them.
Principle of least astonishment
Use mature languages.
Avoid max() and min() functions.
Model Infinites carefully.
console.log(Math.max() > Math.min()); //returns false console.log(Math.max()); //returns -Infinite
console.log(Math.max() > Math.min()); console.log(Math.max()); //returns Exception. Not enough arguments passed. //Max requires at least one argument
These functions belong to the standard Math library. Therefore, they are not easy to avoid.
We can block them on our linters.
We need to be very careful using functions that violate real-world concepts using language tricks.
Inspired by @oliverjumpertz
It's a fun fact about the language that is periodically brought up, but do you know why this actually happens?
Let's take a quick look at Math.max and Math.min to understand the issue.
A thread.16:35 PM - 18 Jul 2021
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
This article is part of the CodeSmell Series.