Skip to content

Commit 01aaddd

Browse files
DanKaplanSESmarco-ippolito
authored andcommitted
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 c00715c commit 01aaddd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

doc/api/vm.md

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

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

11241124
```js
11251125
const vm = require('node:vm');

0 commit comments

Comments
 (0)