DEV Community

loading...

Discussion on: 17 Pro JavaScript tricks you didn't know

Collapse
iminside profile image
Dan Chu

What about this?

const array = Array.from({ length: arraysize }, () => ({ hello: 'goodbye' }))
Enter fullscreen mode Exit fullscreen mode

And if rename arraysize to length then

const array = Array.from({ length }, () => ({ hello: 'goodbye' }))
Enter fullscreen mode Exit fullscreen mode