465
Peak code reuse (eviltoast.org)
you are viewing a single comment's thread
view the rest of the comments
[-] Decq@lemmy.world 2 points 3 weeks ago* (last edited 3 weeks ago)

If string return nan, else % 2

So now you return a number type if it's a string and a boolean if it's an integer. How does that make sense?

The is-even lib exists to sanitize input by throwing an exception which imho is better.

Edit: having looked at the code better. Apparently it still allows string coercion (boo). It only checks for non integer numbers.

[-] bobo@lemmy.ml 1 points 3 weeks ago

Good point, but you can do if === true... and else if === false...

But definitely better to throw an error instead of nan.

this post was submitted on 12 Sep 2025
465 points (100.0% liked)

Programmer Humor

26799 readers
1829 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS