How would I create dynamic variable names in NodeJS? Some examples say to store in the window
variable, but I was assuming that is client-side Javascript. Correct me if I'm wrong.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- Keeping track of variable instances
In node.js there is the
global
context, which is the equivalent of thewindow
context in client-side js. Declaring a variable outside of any closure/function/module as you would in plain Javascript will make it reside in the global context, that is, as a property ofglobal
.I understand from your question that you want something akin to the following:
This in node.js would become:
Generally you would do something like: