+ 10

What's & and | in Javascript?

I came across something like below in Javascript. document.write(2 | 6 & 5); I know the logical && and || but that above I don't know.

10th Apr 2017, 7:52 AM
Wisdom Abioye
Wisdom Abioye - avatar
2 Respuestas
+ 21
Bitwise "AND" (&) and "OR" (|) operator.
10th Apr 2017, 7:57 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 5
| and & are "bitwise or" and "bitwise and" operator. like 2|6 will be (2=001)|(6=110) ->(111=7) 6&5 will be (6=110)&(5=101)->(100=4) and so on. means they are bitwise logic operator, logical operation is applied to each bits.
10th Apr 2017, 8:02 AM
Sandeep Chatterjee