Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- #@Transacional
- tracking-modes
- ExceptionResolver
- COPYOFRANGE
- 단어변환
- assertJ
- TDZ
- wrapper class
- API
- SPOF
- CQS
- Java
- IllegalStateException
- 역정규화
- cross-cutting concerns
- propagation
- RequestMappingHandlerMapping
- Generic method
- hoisting
- NestJS 요청흐름
- generic type
- CORS
- optimistic lock
- 벌크연산
- HandlerMethod
- 프로그래머스
- demand paging
- type eraser
- Transaction
- pessimistic lock
Archives
- Today
- Total
jingyulog
map과 filter 본문
- map과 filter 모두 배열의 내장함수이다.
map
- 배열의 원소를 일괄적으로 변형시킬 때 사용하기 좋다.
const classmate = ["철수","영희","훈이"]
classmate.map((item)=>(item+"어린이"))
const classmate = [
{name: "철수"},
{name: "영희"},
{name: "훈이"}
]
classmate.map((item)=>({name : item.name + "어린이", school : "떡잎유치원"}))
- 실무에서는 컴포넌트의 return 값 안에서 많이 사용한다.
- map을 return 값 안에서 사용하기 위해서 { } 으로 감싸서 사용한다.
// RenderMap 컴포넌트
export default const RenderMap = ()=>{
const classmate = ["철수","영희","훈이"]
return(
{classmate.map( (item)=> <div>{item}어린이</div> )}
)
}
Filter
- 배열의 원소를 필터링해주는 메서드이다.
const num = [1,2,3,4,5,6,7,8,9,10]
num.filter((item)=>(item<=8))
'Language > Javascript' 카테고리의 다른 글
jQuery 사용하기 (0) | 2023.08.06 |
---|---|
비동기 처리법 (0) | 2023.06.03 |
falsy한 값 6가지 (0) | 2023.05.10 |
jQuery란? (0) | 2023.05.02 |
Rest Parameter (0) | 2023.03.21 |