Skip to content

Instantly share code, notes, and snippets.

@bendc
Last active January 15, 2018 08:51
Show Gist options
  • Save bendc/17ea948bea5848a0e112ece8840bcfdd to your computer and use it in GitHub Desktop.
Save bendc/17ea948bea5848a0e112ece8840bcfdd to your computer and use it in GitHub Desktop.
Array of arbitrary number of items
const list = (length, callback) =>
Array.from({length}, (hole, index) => callback(index));
@bendc
Copy link
Author

bendc commented Oct 30, 2017

Example:

list(3, index => index * 2) // [0, 2, 4]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment