I am interested in dynamically creating a table by allocating it, with the variable nbrBoules
:
boules:Boule :[]
boule:Boule; Boule{id,poids}
Method(){
for (var _i = 0; _i < this.nbrBoules; _i++) {
this.boule.id = _i;
alert(_i);
this.boule.poids = 10;
this.boules[_i] = this.boule;
}
After displaying the result of this.boules
, I consistently see
7-10|7-10|7-10|7-10|7-10|7-10|7-10|7-10|
and in my alert I receive 0 - -1 -2 -3 -4 -5 -6 -7
.
I want to understand how this process works in Typescript and why I always seem to obtain the final index value.