title: Difference between (|) Bitwise OR vs (^) Bitwise XOR in JavaScript
body: <p>I'm really getting confused on the use of the <code>|</code> OR vs <code>^</code> XOR in <strong>JavaScript</strong>, illustrated in the simple example below; </p>
  
  <pre><code>(function sayHi(n){
  if(n &lt; 1)   //base case
      return;
  console.log("Hi!!" | "Hello!!") ;
  sayHi(n - 1);   //recurse
  })(5);
  
  
  (function sayHi(n){
  if(n &lt; 1)   //base case
      return;
  console.log("Hi!!" ^ "Hello!!") ;
  sayHi(n - 1);   //recurse
  })(5);
  </code></pre>
  
  <hr>
  
  <pre><code>(function sayHi(n){
  if(n &lt; 1)   //base case
      return;
  console.log(2 | 6) ;
  sayHi(n - 1);   //recurse
  })(5);
  
  
  (function sayHi(n){
  if(n &lt; 1)   //base case
      return;
  console.log(2 ^ 6) ;
  sayHi(n - 1);   //recurse
  })(5);
  </code></pre>
  
  <p>I'm confused about when, how, why, where I should appropriate use <code>|</code> vs <code>^</code>. </p>
  
  <p>Can someone please help me make sense the major difference between <code>OR</code> and <code>XOR</code> operations?</p>
  
  <p>I was reading the documentation for JavaScript from <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators" rel="nofollow noreferrer">MDN web Docs</a> to better understand the concept of bitwise operations, but I am struggling to understand their significant difference.</p>
  
  <p>I just want to make sure I continue to use these operations correctly henceforth. </p>
  
  <p>Thanks a lot for the anticipated help!</p>