What is the node.js equivalent of window["myvar"] = value?

Javascriptnode.js

Javascript Problem Overview


What is the node.js equivalent of window["myvar"] = value?

Javascript Solutions


Solution 1 - Javascript

To set a global variable, use global instead of window.

global["myvar"] = value

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMaiaVictorView Question on Stackoverflow
Solution 1 - Javascriptuser1106925View Answer on Stackoverflow