/    Sign up×
Community /Pin to ProfileBookmark

Variable Variables in JavaScript

I am trying to add a counter part to the end of a variable. Here is the pseudo code:

for (i=1;i<=20:i++){

temp&i=temp&i+1;}

Here I used the & for the variable concatenation. This doen not work in JavaScript. Is there another way????

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJan 06.2003 — I am not familiar with "variable concatenation". What is it supposed to do?
Copy linkTweet thisAlerts:
@VanZylKrugerauthorJan 06.2003 — Because javascript cannot handle integers as variable names I want to add some text infront of numbers and create a variable name i.e.

Temp (variable 1)

1 (counter variable)

When I put them together it creates i new variable Temp1.

No if you have a loop you can create a number of variables with the same properties.

i = 1 to 2

Thus you will get Temp1 and Temp2.....
Copy linkTweet thisAlerts:
@CharlesJan 06.2003 — [font=georgia]This is one of those very rare cases where the [font=monospace]eval[/font] function is useful. See http://developer.netscape.com/docs/manuals/js/client/jsref/toplev.htm#1063795 but know that you might be better off simply using an array.[/font]
×

Success!

Help @VanZylKruger spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...