Guest User

Untitled

a guest
Jun 13th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. function createArray(length, value) {
  2. return Array.apply(null, new Array(length)).map((i, index) => typeof value === 'function' ? value(i, index) : value)
  3. }
  4.  
  5. createArray(10, (item, index) => ({ a: index }) )
  6.  
  7. createArray(10, 'lala')
Add Comment
Please, Sign In to add comment