DEV Community

Discussion on: Why did Array.from()work?

Collapse
trainingmontage profile image
Jeff Caldwell Author

Got it. So, copying the HTMLCollection into a new array using Array.from() also copied all of the references to the original, thus changes to the copy reflected back to the DOM. That seems convenient and dangerous at the same time.

Collapse
lucis profile image
Lucis

Yeah, right!

This is the nature of working with DOM elements, don't know if I'm just used to it. It's very reference-y and with a bunch of side-effects, I believe that's why we use libs like React, since we almost don't have to deal with this.