What's & and | in Javascript? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 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 ответов
+ 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