Map
메모리를 할당하고, return 값을 저장한다.
값을 기존의 배열을 가지고 새로운 배열을 생성한다.
대신 기존의 배열의 값은 바뀌지 않는다.
새로운 배열을 변수에 담을 수 있다.
forEach()
배열의 요소를 한번씩 실행한다.
새로운 배열을 리턴하는 map과 달리 항상 undefiend를 리턴한다.
https://www.freecodecamp.org/news/4-main-differences-between-foreach-and-map/
The Differences Between forEach() and map() that Every Developer Should Know
JavaScript has some handy methods which help us iterate through our arrays. The two most commonly used for iteration are Array.prototype.map() and Array.prototype.forEach(). But I think that they remain a little bit unclear, especially for a beginner. Beca
www.freecodecamp.org
'공부자료 > 자바스크립트' 카테고리의 다른 글
find() Method (0) | 2022.03.16 |
---|---|
ES6 특징, 변수들 정리 및 요약 (0) | 2022.03.04 |
파이어베이스 타임스탬프를 자바스크립트로 표시 (0) | 2022.01.12 |
자바스크립트 날짜 계산하기 (0) | 2021.12.19 |
브라우저인지 확인하는 조건문 (0) | 2021.12.04 |