๐ Coding Study/React, JS
filter(), ํํฐ ํจ์
๋นต๋ชจ๋ฃจ
2023. 10. 9. 23:23
- ๋ฐฐ์ด์ ์์๋ฅผ ์กฐ๊ฑด์ ๋ฐ๋ผ์ ํํฐ๋ง
- ์กฐ๊ฑด์ ๋ง์กฑํ๋ ์์๋ก ์ด๋ฃจ์ด์ง ์๋ก์ด ๋ฐฐ์ด์ ๋ฐํ
const numbers = [1, 2, 3, 4, 5, 6];
const evenNumbers = numbers.filter((number) => {
return number % 2 === 0;
});
// evenNumbers ์๋ [2, 4, 6]
LIST