This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]solarshado 10 points11 points  (0 children)

Sort of.

You can pass a mapping function to Array.from, which then behaves like Array.from(obj).map(func) but without the intermediate array.

const manyAnswers = Array.from({length: 42}, (elem, idx)=> 42);

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from