title: Javascript Variables as Object Pointers
body: <p>I have a question out of curiosity. So I looked into how JS handles variable assignment and I get it. <a href="https://stackoverflow.com/questions/509579/how-does-variable-assignment-work-in-javascript">How does variable assignment work in JavaScript?</a></p>
  
  <p>But the same principle doesn't seem to exhibit itself in the following code I am working on:</p>
  
  <pre><code>var temp = playlist1[0];
  playlist1[0] = playlist1[1];
  playlist1[1] = temp;
  </code></pre>
  
  <p>I know this is a standard way to swap array elements. But if temp is pointing at <code>playlist1[0]</code>, and <code>playlist1[0]</code>'s contents are changed to <code>playlist1[1]</code>'s then how come I don't end up with two <code>playlist1[1]</code> values in a row?</p>