Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q827 Is there a way to use indexed variables, besides using arrays?

You are here: irt.org | FAQ | JavaScript | Object | Q827 [ previous next ]

You can use the eval() method to evaluate text strings:

<SCRIPT LANGUAGE="JavaScript"><!--
// set up 10 variables:

for (var i=0; i<10; i++)
    eval('var var' + i + ' = ' + (i*i));

// show their value:

for (var i=0; i<10; i++)
    alert(eval('var' + i));
//--></SCRIPT>

Feedback on 'Q827 Is there a way to use indexed variables, besides using arrays?'

©2018 Martin Webb