title: Array passed as parameter but reassignment within function fails?
body: <pre><code>function foo(a) {
    a = a.map(function(x) {return 0;});
  }
  
  var A = [1,1,1];
  foo(A);         //seems like A should now be [0,0,0]
  console.log(A); //nope its [still 1,1,1]. debugging shows that the parameter a in foo changes properly to [0,0,0] but does not transfer to A
  A = [0,0,0];    //force A to [0,0,0] now
  console.log(A);
  function bar(a) {
    A = A.map(function(x) {return 1;}); //checking if i can force it back to [1,1,1] using this slight change
  }
  bar(A);
  console.log(A); //this works
  </code></pre>
  
  <p>So why does foo not work? </p>
  
  <p>A is passed into parameter a for <code>foo</code>, so foo's code should <code>run</code> as <code>A = A.map(whatever)</code>, just like in <code>bar?</code> I have some vague guess about it being how <code>javascript</code> handles <code>array</code> <code>pointers</code> in <code>assignment</code> or something.</p>