4 ms·
isOdd and isEven pop up often but they and all those other packages were explicitly created for the sole purpose of boosting the author's profile. https://news
by SenHeng 4y ago
isOdd and isEven pop up often but they and all those other packages were explicitly created for the sole purpose of boosting the author's profile.
https://news.ycombinator.com/item?id=29241943 https://news.ycombinator.com/item?id=29241943
- dncornholio 4y agotoo be honest, a comment of someone doesn't make it true. It could be he has actual use cases for these repositories. Just that someone thinks it should'nt be used like this, doesn't mean it's true. It seems like a lot of people think they think how npm should work, while forgetting to see how npm actually works. There's even an example of a well respected npm author that has repositories with just a few lines.. Y'all just love to hate on npm
- oneeyedpigeon 4y ago> It could be he has actual use cases for these repositories. If that were true, it would be useful for the author to actually explain that in his repo documentation. As it is, concluding that this is a joke is by far the most reasonable response.
- smoldesu 4y agoThe "joke" is that you can determime whether a number is odd or even with a modulo in half the code and a fraction of the storage space of a library. There is no use case for it because it's a built-in feature of the language, and in the age of inane web bloat, supply chain attacks and Javascript cargo-culting, I think laughing at stuff like this is perfectly warranted.
- layer8 4y ago> you can determime whether a number is odd or even with a modulo Or you could check the lowest bit. Better to abstract away from that implementation decision. ;)
- smoldesu 4y agoThat too, but I get the feeling those kinds of operations aren't in Javascript's standard library...
- layer8 4y ago`my_number & 1 == 0` works.
- c0wb0yc0d3r 4y agoJavaScript does have bitwise operators. Something I was surprised by was that numbers are stored as 64 bit while all of the bitwise operators operate on 32 but numbers. This means that every operation results in a number conversion first.
- recursive 4y agoNot just 64 bit. 64 bit floating point. You can't just get the "low bit". You need to take the exponent into account to figure out which bit of the mantissa to grab. It's intrinsically more computationally difficult than is-odd on a real integer.