title: How come if a = b, then b = a?
body: <p>Let me explain. I have the following piece of code : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let a = [1, 2, 3];
  let b = a;
  b.splice(2, 1);
  console.log("a: " + a);
  console.log("b: " + b);</code></pre>
  </div>
  </div>
  </p>
  
  <p>I would have expected to get something like :</p>
  
  <pre><code>a = [1, 2, 3];
  b = [1, 2];
  </code></pre>
  
  <p>However, after running the code, it turns out both "a" and "b" equal [1, 2]. I am really confused, since "b" should only have been assigned a copy of "a", instead of acting as some sort of a pointer to "a". I wonder if it is because JS handles arrays (objects) differently of if it is something specific to the splice function. I would also like to know how you would bypass that odd behavior.</p>
  
  <p>Thanks for your time.</p>