Skip to content

Instantly share code, notes, and snippets.

@pixelkritzel
Created June 11, 2018 10:51
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 pixelkritzel/4455e3aebb12f6f486eb9517d79216ec to your computer and use it in GitHub Desktop.
Save pixelkritzel/4455e3aebb12f6f486eb9517d79216ec to your computer and use it in GitHub Desktop.
function createArray(length, value) {
return Array.apply(null, new Array(length)).map((i, index) => typeof value === 'function' ? value(i, index) : value)
}
createArray(10, (item, index) => ({ a: index }) )
createArray(10, 'lala')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment