Skip to content

Instantly share code, notes, and snippets.

@aheckmann
Created August 11, 2011 13:35
Show Gist options
  • Save aheckmann/1139664 to your computer and use it in GitHub Desktop.
Save aheckmann/1139664 to your computer and use it in GitHub Desktop.
global.hi = "Hello";
goodbye = "See ya";
global = Object.freeze(global);
console.error('global.hi: %s', hi);
console.error('global.goodbye: %s', goodbye);
hi = "Nice to see you";
console.error('global.hi overridden? %s', hi === "Nice to see you");
try {
x = "oops i leaked a global variable";
} catch (err) {
//console.error(err.stack);
}
console.error('successfully leaked a variable?: %s', 'undefined' !== typeof x);
console.error('lets require some shiz');
require('./module');
try {
y = "leaked";
} catch (err) {}
console.error('leaked a global in a module? %s', 'undefined' !== typeof y);
hi = "howdy";
console.error('can override a global within in module? %s', hi === 'howdy');
@gjohnson
Copy link

Dropping window = Object.freeze(window); in our intranet! Thanks! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment