2
When I run the javascript code below:
var dados = Array();
for (var i = 0; i < 2; ++i) {
dados.push({index: i});
console.log(dados);
}
The browser console output for the first interaction will be:
[0: {index: 0}, 1: {index: 1}, length: 1]
And for the second interaction it will be:
[0: {index: 0}, 1: {index: 1}, length: 2]
As we can see, length is printed correctly according to the interaction, but the objects of the Array are printed in their entirety. Because this occurs?
In your example it seems to me
x
would bei
.– Pagotti
True. It’s been corrected.
– Max Porcento
Now you left me in doubt too! I had never noticed that haha
– David Alves
Probably because arrays and objects are passed by reference, the browser must change their value when there is a change via code (only speculating)
– Costamilam