Contact: aviboots(AT)netvision.net.il
39,911 questions
51,843 answers
573 users
const str = 'javascript'; const arr = [...str]; arr.forEach((ch, index) => { console.log(ch, index); }); /* run: "j", 0 "a", 1 "v", 2 "a", 3 "s", 4 "c", 5 "r", 6 "i", 7 "p", 8 "t", 9 */
const str = 'javascript'; for (let i = 0; i < str.length; i++) { console.log(str[i], i); } /* run: "j", 0 "a", 1 "v", 2 "a", 3 "s", 4 "c", 5 "r", 6 "i", 7 "p", 8 "t", 9 */