I\'m trying to implement XOR in javascript in the following way:
// XOR validation if ((isEmptyString(firstStr) && !isEmptyString(secondStr)) |
You are doing an XOR of boolean values which is easy to model into a bitwise XOR (which Javascript has):
var a = isEmptyString(firstStr) ? 1 : 0; var b = isEmptyString(secondStr) ? 1 : 0; if(a ^ b) { ... }
http://www.howtocreate.co.uk/xor.html