Bitwise operators will convert Number which is 64-bit precision IEEE-754 to 32-bit signed integer. So you will lose precision if your number is over 2**32, and will get -ve value if your number is between 2**31 and 2**32. I think that's why Airbnb eslint rules forbidden bitwise operators.
I agree with AirBnB, don't use them unless you're building something really different/special that might call for some fancy bitwise operations (like emulating a CPU in JS or something like that)
But also, when is your average CRUD app going to hit a number as high as 2**31? Maybe in high level finance or sites with above average traffic (like reddit)
9
u/eGust Mar 19 '19
Bitwise operators will convert Number which is 64-bit precision IEEE-754 to 32-bit signed integer. So you will lose precision if your number is over 2**32, and will get -ve value if your number is between 2**31 and 2**32. I think that's why Airbnb eslint rules forbidden bitwise operators.