Skip to content

Instantly share code, notes, and snippets.

@martinhj
Last active April 2, 2019 07:02
Show Gist options
  • Save martinhj/da35632a9de5b4cffb13e86bb17f60e1 to your computer and use it in GitHub Desktop.
Save martinhj/da35632a9de5b4cffb13e86bb17f60e1 to your computer and use it in GitHub Desktop.
Create and fill array of given size
// create and fill array of given size
const arrayWithNumbers = Array(4).fill(null).map((u, i) => i) [0, 1, 2, 3]
// or
const newArrayWithNumbers = [...Array(4)].map((u, i) => i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment