Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

[web] Is this possible with javascript?

This topic is 4250 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In javascript is it possible to do something like this:
// i do know of arrays, but i remember seeing something like done
// but can't remember how, does anyone know?
var a1;
var a2;
var a3;
var a4;
var a5;

for(var i=0;i<5;i++) {
   a+i = "ssss";
}


thanks

Share this post


Link to post
Share on other sites
Advertisement
Use the eval function:


var a1;
var a2;
var a3;
var a4;
var a5;

for(var i=1;i<6;i++) {
eval("a" + i + " = \"ssss\"");
}


(o, and start i at 1)

Share this post


Link to post
Share on other sites
check out arrays. it's easier to work with them :)
than again, just ignore this in case you need something that specific

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!