daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top