Can anyone explain the difference in behaviour between Internet Explorer and Firefox in regards to the below:
var myNamespace = (function () {
var exposed = {};
exposed.myFunction = function myFunction () {
return "Works!";
}
console.log(myFunction());
// IE: "Works!"
// Firefox: ReferenceError: myFunction is not defined
console.log(exposed.myFunction());
// IE: "Works!"
// FF: "Works!"
return exposed;
})();
console.log(myNamespace.myFunction());
// IE: "Works!"
// FF: "Works!"
In internet explorer this method allows me to call my function from inside my namespace function by using either myFunction() or exposed.myFunction().
Outside my namepsace function I can use myNamespace.myFunction()
In Firefox, the results are the same with the exception of the bare named function call which does not work.
Should it work? If it shouldn't, then why not?
If it should then is this a known bug?