What's the difference between ( | ) and ( || )?

前端 未结 7 1222
故里飘歌
故里飘歌 2020-12-01 14:08

What\'s the difference between | and || in Javascript?

Furthermore, what\'s the difference between & and &&<

7条回答
  •  無奈伤痛
    2020-12-01 14:55

    To explain a little more in layman's terms:

    && and || are logical operators. This means they're used for logical comparison;

    if (a == 4 && b == 5)
    

    This means "If a equals to four AND b equals to five"

    | and & are bitwise operators. They operate on bits in a specific fashion which the wiki article explains in detail:

    http://en.wikipedia.org/wiki/Bitwise_operation

提交回复
热议问题