2
I am using an array, where when giving a console.log
The same shows 2 items inside, just below in another console.log
with length
it marks 1, but it is certain to have 2 items in the array.
Code:
console.log(av)
console.log(av.length)
Previously, using the function slice()
, she repeated all arrays when giving a push()
. Then I had to get one to use the for()
.
In the above example the variable is global.
In the image itself indicates
length:2
. If it appears to him1
it is because anything in the middle has tampered with the array– Isac
Put the code here for us please
– Bruno de Sales
@Isac The console.log is one below the other (line: 462 and 463)... I suspect that one of the problems is not to appear [array(124)][Array(123)] in the title.
– abcd
@Brunomorales The code is very big, tomorrow I will unlock it and try to post part of it...
– abcd
Hi @abcd! I think this question is answered by another that I have marked now. Basically what the browser shows on the console is changed after the moment the
console.log
run, because it is an array/pointer to the original. If you doconsole.log(JSON.stringify(av));
the result will already be as expected.– Sergio
@Sergio Thanks, that was right,
console.log
there was a push. And that’s what he was doing. ATT– abcd