What happens if I declare two variables with the same name and scope?
var foo = (function() {
return {
alertMe: function() {
alert("foo1");
}
}
})();
var foo = (function() {
return {
alertMe: function() {
alert("foo2");
}
}
})();
foo.alertMe();
I'm asking because I'm dynamically loading little portlets on my website and each portlet has its own script tag with a JavaScript module. The problem is, users can duplicate portlets which means there is a good chance something like the above may happen.