The MDN docs describe the Array.from() syntax as such;
// Arrow function
Array.from(arrayLike, (element) => { ... } )
Array.from(arrayLike, (element, index) => { ... } )
Array.from(arrayLike, (element, index, array) => { ... } )
It also provides an example range function like this;
const range = (start, stop, step) => Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step));
I'm trying to understand exactly how this code works and I'm confused about two things:
1.) How is the { length: (stop - start) / step + 1} functioning as an arrayLike object here? Wouldn't that just result in a an object {length: number} ?
2.) What's going on with the _ in the (_, i) passed in as the index?