I want to create multiple object using a class for example:
function _Class(_number) {
this.numer = _number;
}
and i want to make 36 objects with the same attributes but different values. I stuck almost on beggining because i used loop :
for (var i = 0; i < 37; i++) {
name="number_"+i;
var name=new _Class(i);
}
and after this code i can't acces to any object. Is there a way that I can create a variable which name is value of array ?
All code:
//test
function test(x){
for (var i = 0; i < 37; i++) {
document.write(x);
}
}
var pola = [0, 32, 15, 19, 4, 21, 2, 25, 17, 34, 6, 27, 13, 36, 11, 30, 8, 23, 10, 5, 24, 16, 33, 1, 20, 14, 31, 9, 22, 18, 29, 7, 28, 12, 35, 3, 26, 0];
var nazwy_obiektow = new Array(100);
for (var i = 0; i < 37; i++) {
nazwy_obiektow[i] = "liczba_" + i;
}
function _Klasa_Liczb() {
this.numer = 1;
}
for (var i = 0; i < 37; i++) {
var nazwy_obiektow[i]=new _Klasa_Liczb;
}
test(liczba_0);