Skip to content

@herby /code.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
runInThisContext fails to run within the context of the caller; it instead runs in root context
var vm = process.binding('evals').Script;
var ctx = vm.createContext({vm:vm});
Object.foo = 1;
console.log('Object.foo ', Object.foo);
console.log('this Object.foo ', vm.runInThisContext("Object.foo"));
console.log('new Object.foo ', vm.runInNewContext(
'Object.foo=2; Object.foo', {vm:vm}));
console.log('new this Object.foo ',vm.runInNewContext(
'Object.foo=2; vm.runInThisContext("Object.foo")', {vm:vm}));
vm.runInContext('Object.foo = 2', ctx);
console.log('ctx Object.foo ', vm.runInContext(
'Object.foo', ctx));
console.log('ctx this Object.foo ', vm.runInContext(
'vm.runInThisContext("Object.foo")', ctx));
Object.foo 1
this Object.foo 1
new Object.foo 2
new this Object.foo 1
ctx Object.foo 2
ctx this Object.foo 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.