A Set, a string, a Map, a NodeList or {length: 3} are loose wagons with no locomotive: Array.from builds a new train and Mr. Wiryo loads it one by one, while…
The key idea
Array.from takes iterables AND array-likes; spread only iterables
Common mistakes
Objects in an Array.from result change when the source changes The copy is shallow: the objects in it are still the same references. The same as spread in that respect.
Try it in this playground
Turn a Set into an array The duplicates are gone in the Set; Array.from loads the rest into a new train.
Spread on { length: 3 } With no iterator, spread throws a TypeError. Array.from still works.
Use Array.from(x, fn) Convert and map at once; with { length: 5 } it makes a range of numbers.
Change a box through the copy Pick the array of boxes, run Array.from, then press hasil[0].kg = 9.