title: JavaScript Copy Array By Value
body: <p>I have created an array and received another from a php file.
  The data is fine but when i try to copy one array to another, it seems like when i change arr1 then arr2 is also changed.</p>
  
  <p>It is being copied "by reference" and not "by value" as i need</p>
  
  <p>I also tried slice() butit doesn't work, The variable does not being copied at all, not even "by reference" in that way.</p>
  
  <pre><code>// arr1[0] = "Hey";//this array is coming from another file and the data is fine
  var arr2 = [];
  
  arr2[0] = arr1[0];
  arr2[0] += "1"; // right now arr1 and arr2 both has "Hey1" in them.
  </code></pre>
  
  <p>Any ideas?
  Thank You</p>