The self invoking function returns an object with the hi
property, this object is not added to the global scope, so you can directly use the property. Put the result of the function in a variable:
var o = (function(){ var a = function (){ alert("hey now!! "); }; return {"hi":function(){return a;}}; })();
Using a property to call a function will only return the function contained in variable a
, so you need to call the return value from the function to call the function containing the warning:
o.hi()();
Demo: http://jsfiddle.net/Guffa/9twaH/
Guffa source share