Skip to content

Instantly share code, notes, and snippets.

@cloudhead
Created February 24, 2011 05:02
Show Gist options
  • Save cloudhead/841788 to your computer and use it in GitHub Desktop.
Save cloudhead/841788 to your computer and use it in GitHub Desktop.
var vm = require('vm');
var context = {
data: 123,
run: function () {
return this.data;
}
}, result;
result = vm.runInNewContext('this.data', context);
console.log(result); // => 123
result = vm.runInNewContext('this.run()', context);
console.log(result); // => undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment