Yesterday I learned that these NPM packages exist:
https://www.npmjs.com/package/is-odd
https://www.npmjs.com/package/is-even
https://www.npmjs....
For further actions, you may consider blocking this person and/or reporting abuse
Haha I had a very similar post planned - you beat me to it!
The
is-even
package has a dependency -is-odd
lololYeah, but that is some genius level stuff :)
Lol the only thing left is to get it into the react core or something
I was surprised with the is-odd and is-even download amount. But you know, sometimes you just need to know wether it is or not.
Those useless packages have so many downloads, because some basic,useful package use it. And for example webpack use this useful package. So now everyone installing webpack or something that uses webpack (basically any top is framework) is counted as download.
would be more appropriate to say that webpack doesn't actually use is-odd and is-even, one of the dependencies uses it.
I think the idea of your package is actually pretty useful. Just found something similar that has ~2k weekly downloads.
npmjs.com/package/range
My guess is it's just preference for is-odd and is-even.
JS community fascinates me every passing day
Well, that's odd!
Keeps the playing field even!
Gotta check the numbers on that one
thank you for your short work ...
No problem. Thank you for taking the time to read my post.
Why is line "num - num === 0" needed?
Ambar explained it pretty well.
I think the best, and easiest way, to check if a variable is of type 'number' in JS, is to use the
method.
It will weed out anything that is not a number, including NaN and Infinity.
If simply true is returned, input NaN (not a number) will also return true. It turns out typeof NaN is number. Also NaN - NaN is NaN so this expression num - num === 0 returns true only when num is a number except NaN.
Yeah. And same goes for Infinity and -Infinity.