Skip to main content
January 24, 2008
Question

Syntax for creating varialbes dynamically

  • January 24, 2008
  • 2 replies
  • 266 views
I am trying to create a set of date variables with different instance name inside a for loop but it is not working so well at the moment. Here is the code that is giving me an error. Can anyone tell me where my syntax is wrong? Thanks.

for(i=startDay; i<=monthTotal+startDay-1; i++) {
var ["dateInfo"+i]:Date;
}
This topic has been closed for replies.

2 replies

Inspiring
January 24, 2008
how far i know is impossible to make dynamic variables but you can deffine array and store your data into array.
Inspiring
January 24, 2008
I think you would need to use an object to hold these values:

obj=new Object();

for (i=0;i<10;i++) {
obj["info"+i]="my value is " + i;
}