Contact: aviboots(AT)netvision.net.il
39,851 questions
51,772 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 ] */