When you pass the variable o in your example, you pass the value undefined, not a link to anything. What you need to do is send the parent objects. In this case, the window object (assuming you are using a browser).
(function (p, name) { p[name] = function() { alert('test'); }; })(window, "o"); o();
This is passed in the window object and the name of your new function. Then it assigns your function to the window, and now it is available for calling. However, if you intend to use closure, I would suggest simply assigning the function directly.
function o() { alert('test'); }; o();
MillsJROSS
source share