Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 609
MaiaVictor Avatar asked Jun 11 '12 17:06

MaiaVictor


People also ask

What is window equivalent in NodeJS?

In a browser it is named window , for Node. js it is global , for other environments it may have another name.

Is there a window object in NodeJS?

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.

What is the value of NodeJS to developers?

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.

Can I use visual code for NodeJS?

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.


1 Answers

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

global["myvar"] = value 
like image 64
user1106925 Avatar answered Sep 18 '22 23:09

user1106925