If one array is assigned to another array, why is one less in the new array?

the original array looks like this:

clipboard.png

:

clipboard.png

Mar.21,2021

when running console.log (arr), chrome prints out the length of the array, that is, "6", because the argument is an array.

then you changed the array, now there are only five elements, but chrome will not take the initiative to change the printed "6" to "5", all the printed results will not change.

when you expand this array, you are looking at the latest information, so it is "5".

the implication is that you changed the array after console, but you don't know how to change it until you put it in the code.


the answer upstairs is not quite right, at least it doesn't fit all the circumstances

I guess the problem is that the assignment does not trigger the recalculation of the array in the frame. If it is a vue framework, you can use the this.$set () method to recalculate it

Menu