Why is there no logical xor in JavaScript?

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

Why is there no logical xor in JavaScript?

19条回答
  •  悲&欢浪女
    2020-11-29 17:25

    Check out:

    • Logical XOR in JavaScript

    You can mimic it something like this:

    if( ( foo && !bar ) || ( !foo && bar ) ) {
      ...
    }
    

提交回复
热议问题