Skip to content

Instantly share code, notes, and snippets.

@emersondemetrio
Last active April 24, 2024 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emersondemetrio/605d03561c0f85e07c2beec0d7bf2341 to your computer and use it in GitHub Desktop.
Save emersondemetrio/605d03561c0f85e07c2beec0d7bf2341 to your computer and use it in GitHub Desktop.
Fill array with something
// 2024 version
const arr = Array.from({ length: 30 }, (_, id) => ({
id,
name: `item-${id}`
}));
// 2018 version
const arr = Array.from(Array(30), (_, id) => ({
id,
name: `item-${id}`
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment