title: Passing a parameter as a pointer in JavaScript
body: <p>Take a look at the following code:</p>
  
  <pre><code>var o;
  
  (function (p) {
      p = function () {
          alert('test');
      };
  })(o);
  
  o(); // Error: 'o is not a function'
  </code></pre>
  
  <p>In the above function I am creating an anonymous function that takes one parameter, which self-invokes with a previously-created object passed as a parameter.
  Then I am pointing this object to a function (from inside the new scope) and ultimately (trying) to invoke it from outside.</p>
  
  <p>My question is, how can I pass that argument 'by reference' as to change the pointer it points to ?</p>