diff --git a/index.js b/index.js index 96e4c17..36ebef2 100644 --- a/index.js +++ b/index.js @@ -109,9 +109,11 @@ Script.prototype.runInNewContext = function (context) { var ctx = Script.createContext(context); var res = this.runInContext(ctx); - forEach(Object_keys(ctx), function (key) { - context[key] = ctx[key]; - }); + if (context) { + forEach(Object_keys(ctx), function (key) { + context[key] = ctx[key]; + }); + } return res; };