Is there anyway to implement XOR in javascript

前端 未结 18 674
孤城傲影
孤城傲影 2020-12-24 10:53

I\'m trying to implement XOR in javascript in the following way:

   // XOR validation
   if ((isEmptyString(firstStr) && !isEmptyString(secondStr)) |         


        
18条回答
  •  粉色の甜心
    2020-12-24 11:47

    Try this: function xor(x,y) var result = x || y if (x === y) { result = false } return result }

提交回复
热议问题