250x250
Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

y.developer

[TIL] Day 15 깃허브 세팅부터 차근차근 본문

카테고리 없음

[TIL] Day 15 깃허브 세팅부터 차근차근

y.developer 2023. 10. 25. 20:31
728x90

2023.10.25 수

 

보충반 강의 듣는중... 조금 이따가 정리

 

지금 듣는 실시간 강의 내용

 

forEach(value, index) : return X

filter(value, index) : return O (배열 아웃풋)

 

value : 값

index : 순서

 

작동 방식은 똑.같.다

 

 

const arr01 = ["홍길동", "홍길순", "옹길순"];

const result = arr01.filter(function(val) {

if (val.includes("홍길")) {

return true;

} else {

return false;

}

})

 

const arr01 = ["홍길동", "홍길순", "옹길순"];

const result = arr01.filter((val) => val.includes("홍길"));

 

 

find 배열을 입력값으로 받고 조건에 해당되는 첫번재를 출력 (filter와 사용방법 똑같다)(filter를 걸로 0번째 인덱스에 접근하는 것과 똑같다)

 

 

map 배열 요소의 개수만큼 어떤 값이라도 할당이 된다 = return에 있는 것을 이용해서 새로운 배열 생성

return{
 key: 순서,
 calue: 값 * 2,
}

 

 

 

const arr = [1, 2, 5, 10, 4];

 

// 배열체이닝

const result = arr.map((a) => {

return a * 2;

}).filter((a) => {

return a >= 5;

}).forEach((a) => {

console.log(a);

})

 

 

filter.map

엄청 많이 쓴다

 

728x90