I'd say that Array.from() isn't the most handy as a substitute for Array.map(). Rather, it's handy for transforming iterables that aren't already arrays.
Like, to get the names of commenters on this page, try this in the dev tools console:
The NodeList returned from document.querySelectorAll isn't an array, but this lets you convert it to an array while performing a transformation at the same time.
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I'd say that
Array.from()
isn't the most handy as a substitute forArray.map()
. Rather, it's handy for transforming iterables that aren't already arrays.Like, to get the names of commenters on this page, try this in the dev tools console:
The NodeList returned from
document.querySelectorAll
isn't an array, but this lets you convert it to an array while performing a transformation at the same time.