I have need to create arrays dynamically using JavaScript/JQuery
.
What I did is as follows:
var count = 5;
for(var j=0;j<count;j++){
var arrayname = "array"+j;
var arrayname = [];
}
After creation I am expecting arrays array0[],array1[],array2[],array3[],array4[]
So I printed as
alert(array0);
But I am getting error as follows:
Uncaught ReferenceError: array0 is not defined
It occurred because array0[]
is not global its bound is only inside that for loop. How can I create dynamic array so that all the arrays can be accessed from outside also?