I'm trying to understand the following scenario where I have defined a function in one scope and want to access it another.
I have two different JavaScript files, helper.js and main.js, and both have a self-invoking function:
helper.js:
var outerShowData;
(function(){
var innerShowData = function(param1, param2){
alert("Data : "+ param1 +" - "+ param2);
}
outerShowData = innerShowData;
})();
main.js:
(function(){
outerShowData("alpha", "beta");
outerShowData("gamma", "theta");
})();
If I first include the helper.js in my page and then the main.js, this works perfectly in Firefox, Safari and Google Chrome. However it doesn't work in IE8.
Could anyone point out what am I doing wrong here?
I wrote the self-invoking function just not to dirty up the global scope. Any help in this direction would greatly help me.