Why is there no logical xor in JavaScript?

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

Why is there no logical xor in JavaScript?

相关标签:
19条回答
  • 2020-11-29 17:49

    Try this short and easy to understand one

    function xor(x,y){return true==(x!==y);}
    
    function xnor(x,y){return !xor(x,y);}
    

    This will work for any data type

    0 讨论(0)
提交回复
热议问题