How to dynamically generate variables in JavaScript?
My goal is to dynamically generate variables foo1, foo2 and foo3 and
assign bar to them using the following code:
for (var i=1;i<=3;i++) {
myapp.set({ foo+i: "bar" })
}
I tried using eval on foo by it doesn't work. Any ideas?
No comments:
Post a Comment