I have a question out of curiosity. So I looked into how JS handles variable assignment and I get it. How does variable assignment work in JavaScript?
But the same principle doesn't seem to exhibit itself in the following code I am working on:
var temp = playlist1[0];
playlist1[0] = playlist1[1];
playlist1[1] = temp;
I know this is a standard way to swap array elements. But if temp is pointing at playlist1[0]
, and playlist1[0]
's contents are changed to playlist1[1]
's then how come I don't end up with two playlist1[1]
values in a row?