Skip to content

Commit 8f9f5db

Browse files
authoredMar 9, 2024··
doc: document that const c2 = vm.createContext(c1); c1 === c2 is true
- As far as I can tell, the documentation didn't say this, so I was left wondering if there is a difference between `c1` and `c2` in `const c2 = vm.createContext(c1);` According to my own tests, they are equivalent. I thought it was worth documenting as it would've saved me a bit of time if this information were written down. PR-URL: #51960 Refs: #51946 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent bda66ad commit 8f9f5db

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

Diff for: ‎doc/api/vm.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1117,13 +1117,13 @@ changes:
11171117
[Support of dynamic `import()` in compilation APIs][].
11181118
* Returns: {Object} contextified object.
11191119

1120-
If given a `contextObject`, the `vm.createContext()` method will [prepare
1121-
that object][contextified] so that it can be used in calls to
1122-
[`vm.runInContext()`][] or [`script.runInContext()`][]. Inside such scripts,
1123-
the `contextObject` will be the global object, retaining all of its existing
1124-
properties but also having the built-in objects and functions any standard
1125-
[global object][] has. Outside of scripts run by the vm module, global variables
1126-
will remain unchanged.
1120+
If given a `contextObject`, the `vm.createContext()` method will [prepare that
1121+
object][contextified] and return a reference to it so that it can be used in
1122+
calls to [`vm.runInContext()`][] or [`script.runInContext()`][]. Inside such
1123+
scripts, the `contextObject` will be the global object, retaining all of its
1124+
existing properties but also having the built-in objects and functions any
1125+
standard [global object][] has. Outside of scripts run by the vm module, global
1126+
variables will remain unchanged.
11271127

11281128
```js
11291129
const vm = require('node:vm');

0 commit comments

Comments
 (0)
Please sign in to comment.