By the way, the Array.from
function was meant for converting iterables into arrays. However, I have never used it for that purpose because using the spread operator is a nicer way to convert iterables into arrays.
// when not mapping
const a = Array.from(someIterable);
const b = [...someIterable];
// when mapping
const c = Array.from(someIterable, mappingFn);
const d = [...someIterable].map(mappingFn);
In fact, the only time I ever use Array.from
is specifically when I want to create an array of a specific length, i.e. I always write something like Array.from({ length: n }, (_, i) => …)
. So, I personally never use Array.from
for its intended purpose. I only ever use it to create arrays of a specific length.
This is all the more reason to add Array.create
to the language.
Anyway, I think I've done enough bikeshedding for today. I firmly believe that Array.create
is a great addition to the language. From what I read, I also believe that everybody else is of the same opinion. If the committee is so against adding a simple quality of life function to the language, then that's their choice. I've said everything that I want to say.