title: Javascript: Re-assigning a function with another function
body: <p>Let's say I have these two functions:</p>
  
  <pre><code>function fnChanger(fn) {
      fn = function() { sys.print('Changed!'); }
  }
  function foo() {
      sys.print('Unchanged');
  }
  </code></pre>
  
  <p>Now, if I call <code>foo()</code>, I see <code>Unchanged</code>, as expected. However, if I call <code>fnChanger</code> first, I still see <code>Unchanged</code>:</p>
  
  <pre><code>fnChanger(foo);
  foo(); //Unchanged
  </code></pre>
  
  <p>Now, I assume this is because <code>foo</code> is not being passed to <code>fnChanger</code> by reference, but I may be wrong.</p>
  
  <p>Why does <code>fnChanger</code> not change <code>foo</code> to print <code>Changed!</code>?<br>
  Furthermore, how can I get <code>fnChanger</code> to change <code>foo</code> without too much messy syntax?</p>
  
  <p>PS: I'm using node.js to test all this stuff, so that's where the <code>sys.print</code> comes from.</p>