Contact: aviboots(AT)netvision.net.il
40,695 questions
53,044 answers
573 users
const arr = []; for (let i = 0; i < 5; i++) { arr.push(() => i); } m = arr.map(x => x()); console.log(m); /* run: [ 0, 1, 2, 3, 4 ] */
const arr = []; for (const i of [0, 1, 2, 3, 4]) { arr.push(() => i); } m = arr.map(x => x()); console.log(m); /* run: [ 0, 1, 2, 3, 4 ] */