I know that && and || are used in comparisons as AND and OR, respectively.
But what about the & and | operators? What are they used for?
Here’s the code I’m testing:
var a = 2;
var b = 3;
var c = a & b;//2
var d = a | b;//3
Difference between && , || and &, | ….
They are bitwise AND and OR respectively. The usage is mainly for low-level (now don’t why you would want that here, there may be many applications) operations.
For example:
Similarly there are other operators too:
I could provide the whole list but that would be of no use. Already many answers contain links to excellent resources. You might want to look at those. My answer just gives some idea.