I'm trying to dynamically name multiple variables with a for loop and can't get the syntax, can anyone help?
for (var U=1; U>2; U++){
"test"+String(U)=U;
}
kglad - 09 Jul 2008 21:40 GMT
use array notation to convert strings to objects:
for (var U=1; U>2; U++){
this["test"+String(U)]=U;
// or this["test"+U]=U;
}
badmonkey91 - 09 Jul 2008 22:08 GMT
kglad - 09 Jul 2008 22:16 GMT