Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
157
rated 0 times [  164] [ 7]  / answers: 1 / hits: 20548  / 12 Years ago, wed, september 26, 2012, 12:00:00

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.


More From » node.js

 Answers
30

Generally you would do something like:



var myVariables = {};
var variableName = 'foo';

myVariables[variableName] = 42;
myVariables.foo // = 42

[#82912] Monday, September 24, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lesli

Total Points: 348
Total Questions: 105
Total Answers: 119

Location: United States Minor Outlying Island
Member since Fri, Jan 6, 2023
1 Year ago
;