โ
๋ฐฐ์ด ๋ด์ฅ ํจ์(์๋ฐ์คํฌ๋ฆฝํธ)
forEach : for๋ฌธ ๋์ฒด, ๋ฐฐ์ด ์์ ์๋ ๋ชจ๋ ์์๋ค์ ๋ชจ๋ ์ถ๋ ฅ const superheroes = ['์์ด์ธ๋งจ', '์บกํด ์๋ฉ๋ฆฌ์นด', 'ํ ๋ฅด', '๋ฅํฐ ์คํธ๋ ์ธ์ง']; //for๋ฌธ์ผ๋ก ๋ฐฐ์ด ์์ ์๋ ๋ชจ๋ ์์ ์ถ๋ ฅ for (let i=0; i { console.log(hero); }); - forEach ํจ์์ ํ๋ผ๋ฏธํฐ๋ก ๊ฐ ์์์ ๋ํ์ฌ ์ฒ๋ฆฌํ๊ณ ์ถ์ ์ฝ๋๋ฅผ ํจ์๋ก ๋ฃ์ด์ค - ์ฝ๋ฐฑํจ์: ํจ์ํํ์ ํ๋ผ๋ฏธํฐ๋ฅผ ์ ๋ฌํ๋ ๊ฒ map : ๋ฐฐ์ด ์์ ๊ฐ ์์๋ฅผ ๋ณํํ ๋ ์ฌ์ฉ, ์๋ก์ด ๋ฐฐ์ด์ด ๋ง๋ค์ด์ง const array = [1,2,3,4,5,6,7,8]; const squared = []; //for๋ฌธ ์ด์ฉ for (let i=0; i { squared.push(n*n); }); console..
2022. 11. 17.