Take a look at the following code:
var o;
(function (p) {
p = function () {
alert('test');
};
})(o);
o(); // Error: 'o is not a function'
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.
My question is, how can I pass that argument 'by reference' as to change the pointer it points to ?