DEV Community

Discussion on: 10 JavaScript array methods you should know

Collapse
thiruppathi profile image
Thiru

Thanks for the article Frugence! 👍

I would like to use [...] SpreadOperator a shorthand alternate to Array.from()

const lisArray = [... document.querySelectorAll('li')];

I wonder is there any major difference between these 2 ways?

Collapse
frugencefidel profile image
Frugence Fidel Author

Take a look here friend, Array.from() vs spread syntax

Collapse
thiruppathi profile image
Thiru

Thanks for the reference friend. 👍

Thread Thread
frugencefidel profile image
Frugence Fidel Author

You are welcome friend

Collapse
dan503 profile image
Daniel Tonon • Edited on

Based on that, the answer is essentially "no, they are practically the same" for most use cases.

For some edge cases they do have differences. In those specific edge cases Array.from() is the better one to use.