When Javascript checks to see if a method can be called, it uses a duck . This means that when you want to call a method foofrom some object that must have a type bar, it does not check whether this object is really barbut checks if it has a method foo.
So in JS you can do the following:
let fakeArray = {length:5};
fakeArray.length
let realArray = [1,2,3,4,5];
realArray.length
The first one looks like a fake javascript array (which has lengthproperties). When it Array.fromgets the value of the property length(in Array.fromcase 5), it creates a real array of length 5.
This type of fakeArray object is often called arrayLike.
The second part is just an arrow function that populates the array with index values (second argument).
This technique is very useful for mocking an object for testing. For instance:
let ourFileReader = {}
ourFileReader.result = "someResult"