A Safer JS Environment
Oh well, apparently I wasn't joking here and I went even further ... so here I am with a weird hack you probably never thought about before ;) A Globally Frozen Environment Have you ever thought about this in the global context? Object.freeze(this); Apparently not even browser vendors such Chrome or Safari since this condition, today, is always false: Object.isFrozen(Object.freeze(this)); , and even if it works as expected after freezing. Firefox and node.js got it right while Opera Next throws an error .. but latter a part ... Stop Any Global Pollution That's right, if you freeze the window or global object, guess what happens here: Object.freeze(this); var a = 123; alert(this.a); // undefined alert(a); // error: a is not defined We cannot even by mistake create a global variable ... there's no lint that could miss that. Moreover, if you are worried about malicious code able to change some global function or constructor, you can stop worrying with proposed freeze call: t...