2 ms·
This is my issue with js; isNaN looks related to NaN in a 1-1 mapping as in, testing ‘x is NaN’ but it doesn’t. So the naming is confusing as it does more than
by anonzzzies 3y ago
This is my issue with js; isNaN looks related to NaN in a 1-1 mapping as in, testing ‘x is NaN’ but it doesn’t. So the naming is confusing as it does more than that, isNotNumeric() or so.
- jalk 3y agoSeems like the author fell into this trap
- eloisant 3y agoYes, even better "isNumber()" because a function that tests a negative can cause confusion and mistakes.
- tetha 3y agoI am ready to oppose any `isFoo` function that doesn't return a boolean. If you ask "Is this a Nan", why would you expect 42 as an answer? Or, "hello". Kinda feels like "Are you at home?" - "Kitchen". It eventually becomes a "yes" through more thought, but eh... I'd much rather call this "normalizeNaN" or something.
- Jtsummers 3y ago`isNaN` does return a boolean though, it doesn't return a normalized value.