Node.js NOT-XOR优化

我一直在寻找一种方法来微观地优化Node.js中的以下逻辑expression式,但是我没有find更好的实现方法:

假设A和Bvariables都是布尔值(复杂方法/expression式的结果):

if ( (A && B) || (!A && !B) ) { return true; } return false; //Obviously the returns are redundant in this case. 

这个expression式的真值表是:

  ╔════╦═══════╦═══════╗ ║ ║ A ║ !A ║ ╠════╬═══════╬═══════╣ ║ B ║ true ║ false ║ ╠════╬═══════╬═══════╣ ║ !B ║ false ║ true ║ ╚════╩═══════╩═══════╝ 

来自前方的感谢!

这个expression是等价的:

 return A === B;