Javascript has a lot of weird features.
Non-transitivity of equality is one pretty weird thing about js, see this meme:
But I have to say, for me the most infuriating thing about js is that it has a fake modulus operator.
In literally every other language: python, C/C++, Julia, Java, whatever, x%y >= 0
is always true. This is just so useful, because for me the biggest use case of the modulus operator is cycling through elements of a list, in which case I really want
0 <= (x-1)%n < n
0 <= (x+1)%n < n
I dunno I find it really annoying that js says things like -1 % 5 = -1
.
It's typical in math to denote the set Z\nZ
by {0,1,\ldots, n-1}
.
Of course it's true that -1 = n-1 \mod n
but I want the reasonable value, not the negative one!
-Aelk
Top comments (0)