Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
31
rated 0 times [  37] [ 6]  / answers: 1 / hits: 18205  / 15 Years ago, wed, december 9, 2009, 12:00:00

how could I declare several js array dynamically?
For example, here is what tried but failed:



 <script type=text/javascript>
for (i=0;i<10;i++)
{
var arr_+i = new Array();
}


Thanks!


More From » arrays

 Answers
88

You were pretty close depending on what you would like to do..



<script type=text/javascript>
var w = window;
for (i=0;i<10;i++)
{
w[arr_+i] = [];
}
</script>


Would work, what is your intention for use though?


[#98108] Sunday, December 6, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
reed

Total Points: 725
Total Questions: 85
Total Answers: 89

Location: Singapore
Member since Sat, Jul 25, 2020
4 Years ago
;