title: Javascript Changing one object also changes the other object
body: <p>In my code snippet I have an object "cat" that I store into two variables "Pelle" and "Kalle".
  If I change the name of Pelle, it also changes the name of Kalle. I believe it has to do with them being references to cat.</p>
  
  <p>How can I avoid this?</p>
  
  <p>How can I change the value of Pelle without changing the name of Kalle?</p>
  
  <p>Is the problem how I store the values in myFunction, or is the problem when I change the name in modify-function? </p>
  
  <pre><code>var cat = {
      name : "Melvin",
      age: : "9",
      eyeColor : "yellow"
  };
  
  var pelle;
  var kalle;
  
  myFunction(cat);
  modify();
  print();
  
  function myFunction(c) {
      pelle = c;   
      kalle = c;
   }
  
   function modify() {
      pelle.name = "Watts";
   }
  
   function print() {
      document.getElementById("demo").innerHTML = pelle.name + " " + kalle.name;
   }
  </code></pre>
  
  <p>Output from print() is Watts Watts. </p>
  
  <p>Desired output is Watts Melvin.</p>