Javascript Boolean Type Prototype XOR

Description

Javascript Boolean Type Prototype XOR


// Adding XOR to the boolean object via its prototype

Boolean.prototype.XOR=function(other){ 
  return (this.valueOf()==true && other==false) || (other==true && this.valueOf()==false);
}

console.log(true.XOR(false));    // true
console.log(false.XOR(false));    // false



PreviousNext

Related