Today I will try my best to ELI5 a concept known as Bitwise Operators, with an example of a real world use case in the second half of this post.

What are they, how do they work?

Bitwise Operators are similar to traditional Logical Operators in that they take two or more values and compare them to each other. The difference ultimately lies In what aspect of the value each operator type is comparing.

While Logical Operators compare the higher level representations of a value (1 is 1, ‘f’ is ‘f’), Bitwise Operators look at the binary, “lower level” forms of the value, and then compare them bit by bit. Oh, and they also only work on integers.

Before I continue, I think this is a good spot to briefly explain how decimal numbers translate to binary, and for the sake of simplicity we will only focus on 0–9.

#binary #bitwise #javascript

Bitwise for Dummies
1.35 GEEK