I was writing some code with a namespace to reduce clutter when I thought that maybe I could stop polluting the namespace all together by creating an anonymous namespace. I just want to make sure that this is valid and there's no hidden gotcha's that I'm not thinking of.
Basically, the code goes like this:
new function() {
// bunch of private helper functions and variables
// ...
this.loadEventHandler = function()
{
// do load stuff
};
this.resizeEventHandler = function()
{
// do resize stuff
};
window.onload = this.loadEventHandler;
window.onresize = this.resizeEventHandler;
};
Is there anything that I'm not taking in to account? This wouldn't be taken out by a garbage collector or something, right?