PDA

View Full Version : var this["myVariable" + i] = new Object();



OM2
July 31st, 2005, 05:50 AM
I want to have the following code:
var this["myVariable" + i] = new Object();The compiler throws an error.

I've also tried:
var eval("myVariable" + i) = new Object();This also gets rejected.

I need to have the code in a for loop and hence the syntax.

Where am I going wrong?

Thanks.


OM

beanSoldier
July 31st, 2005, 06:28 AM
take away the var part:



this["myVariable" + i] = new Object();

OM2
July 31st, 2005, 06:41 AM
ya... that's what i did in the end.
but i want to have a temporary variable and not a permanent variable.

Dauntless
July 31st, 2005, 06:44 AM
then delete it...

delete this["myVariable"+i];