Skip to content

Instantly share code, notes, and snippets.

@3rd-Eden
Created July 22, 2010 15:05
Show Gist options
  • Save 3rd-Eden/486093 to your computer and use it in GitHub Desktop.
Save 3rd-Eden/486093 to your computer and use it in GitHub Desktop.
How to easily detect leaking globals in Node.js
var natives = process.compile('Object.getOwnPropertyNames((function(){return this}()))','natives.js');
/* some code */
hello_world = "global";
/* some more code */
Object.getOwnPropertyNames((function(){return this}())).forEach(function(key){if( natives.indexOf(key) == -1){console.error(key)}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment