What is the node.js equivalent of window["myvar"] = value
?
In a browser it is named window , for Node. js it is global , for other environments it may have another name.
window object is available in browser environment only. In other environment's, there is no window object. For exp, in Node JS, global is used instead of window object. But Block scope const and let are not windows properties and methods.
Node. js allows developers to use JavaScript to create server-side code, even though traditionally, this language has only been used in the browser to develop client-side code. Combining both sides in the same environment makes it easier to create web servers, which is why Node.
Visual Studio Code has support for the JavaScript and TypeScript languages out-of-the-box as well as Node.js debugging. However, to run a Node.js application, you will need to install the Node.js runtime on your machine.
To set a global variable, use global
instead of window
.
global["myvar"] = value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With