I found the statement [].concat(anotherArray)
is not completely same to the [...anotherArray]
.Especially when we use it to convert NodeList.
I want to iterate a NodeList in Vue template, like this:
<div>{{ [...theUl.children].map(li => li.innerText) }}</div>
There is a problem: Vue converts [...theUl.children]
to [].concat(theUl.children)
and execute it, you can try it yourself, the result is weird and different to [...theUl.children]
: you will get a array like [[li, li, li]].
I don’t konw what happened.Who can explain this?
Thank you!