Does that package exist because JavaScript lacks a modulus operator (I feel like I remember it having one), or because the operator does/doesn’t coerce things into numbers the way you’d expect? Or is it honestly just laziness?
The package is written in javascript and uses the modulus operator.
It's just laziness and a cargo-cult mentality around package granularity that's gotten way out of hand. There's no rational basis for it.
$ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 10 % 3
1
>>> 10 % -3
-2
>>>
$ node
> 10 % 3
1
> 10 % -3
1
In the case we're talking about - is_odd - I don't think it matters, but there is a difference and it could cause some surprises if you're not prepared.edit: I called this operation "remainder" ... but you don't exactly say "10 remainder 3" for this operation. I don't know what to call it, "divide-by-and-return-absolute-of-whats-left" is not very catchy
- JavaScript is consistent with Java, PHP.
- Older C may behave as either Python or JavaScript.
- Modern C behaves like JavaScript.
So basically Python is the outlier here.
[0] https://en.wikipedia.org/wiki/Modulo_operation#In_programmin...