I'm having something strange concerning the length of an array, maybe the problem is obvious and i don't see it. I have an array: this.roles which is an array of simple objects:
this.roles = [
{
GRO_id:1,
ROL_id:1
}
];
When I add objects in it I use the method push with a new object:
this.roles.push({
GRO_id: GRO_id,
ROL_id: ROL_id
});
But when I try to loop on this.roles
the script can't seem to go through all objects, so I tried console.log to see what it gives:
console.log(this.roles); //l.69
console.log(this.roles[0]); //l.70
console.log(this.roles[1]); //l.71
console.log(this.roles.length); //l.72
console.log(this.roles); //l.73
And here are the results:
[Object]
0: Object
1: Object
length: 2
__proto__: Array[0] //l.69
Object {GRO_id: 1, ROL_id: 1} //l.70
Undefined //l.71
1 //l.72
[Object]
0: Object
1: Object
length: 2
__proto__: Array[0] //l.73
Can someone explain to me why I got different length? It's as if the objects were wrapped in a single object, or as if I had accidentally made the variable this.roles reference 2 different arrays...