Skip to content

Instantly share code, notes, and snippets.

@alex-cory
Created July 22, 2017 08:42
Show Gist options
  • Save alex-cory/c6d64de4838ca4caf69af75f98b7e9f3 to your computer and use it in GitHub Desktop.
Save alex-cory/c6d64de4838ca4caf69af75f98b7e9f3 to your computer and use it in GitHub Desktop.
Generate Array [0, ...., N] Function
// Option 1: [0, ...., N]
var array = length => Array.from({ length }, (_, i) => i)
// Option 2: [0, ...., N]
var array = to => Array.from(Array(to), (_, i) => i)
// Option 3: [1, ....., N]
var array = length => Array.from({ length }, (_, i) => i + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment