Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created October 25, 2013 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/7162414 to your computer and use it in GitHub Desktop.
Save isaacs/7162414 to your computer and use it in GitHub Desktop.
function def() {
var myx;
Object.defineProperty(global, 'x', {
get: function() {
return myx;
},
set: function(val) {
console.log('setter!');
myx = val;
}
});
}
def();
var vm = require('vm');
vm.runInThisContext('var x = function x() {}', 'var.js');
vm.runInThisContext('function x() {}', 'decl.js');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment