Why is there no logical xor in JavaScript?

前端 未结 19 2111
忘了有多久
忘了有多久 2020-11-29 17:17

Why is there no logical xor in JavaScript?

19条回答
  •  一向
    一向 (楼主)
    2020-11-29 17:23

    Convert values into Boolean form then take bitwise XOR. It will help with non-boolean values as well.

    Boolean(a) ^ Boolean(b)
    

提交回复
热议问题