So what is the difference between this two functions?
They both create new Array
object. Only difference I found so far is that Array.from
supp
Making Array.prototype
the prototype object for every single array-like "Class" in JS (more importantly, in DOM, where most of the 'array-like' objects live) would be a potential mistake.
What would a .reduce( )
on a list of HTML elements/attributes look like?
Array.from
is the official version of [].slice.call(arrayLike);
with the added benefit of not having to create an unused array, just to create an array.
So really, Array.from
can be polyfilled with function (arrLike) { return [].slice.call(arrLike); }
, and minus native-implementation speed/memory improvements, it's the same result.
This has little to do with map|reduce|filter|some|every|find, which are the keys to living a long and happy life, without the need of micromanaging loops to get things done.