본문 바로가기 메뉴 바로가기

Studying programming

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

Studying programming

검색하기 폼
  • Jimin's Programming (194)
    • Algorithms (54)
    • JavaScript (16)
    • Vue.js (3)
    • Node.js (3)
    • React.js (7)
    • React Native (0)
    • Spring Boot (13)
    • JAVA (58)
    • C++ (17)
    • Programming (19)
    • Computer basics (4)
  • 방명록

javascript map (1)
map vs forEach

map vs forEach map은 새로운 array를 리턴하고 forEach는 original array를 수정하여 리턴한다. -> 즉 기존 array를 남기는 map()을 사용하는 것이 함수형프로그래밍에 더 적합하다. forEach자체는 original array를 return하지만 callback function이 변화를 일으킨다. Example code. let arr = [1,2,3]; const arrMap = arr.map(x => x*2); console.log("arr", arr) //arr [ 1, 2, 3 ] console.log("arrMap", arrMap); //arrMap [ 2, 4, 6 ] arr.forEach((x, index) => arr[index] = x * 3); ..

Programming 2022. 8. 15. 17:13
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • javascript
  • equals()
  • Object type casting
  • substring()
  • math.max
  • algorithm
  • spring boot application
  • hackerrank
  • rest parameter
  • java
  • Collection Framework
  • HashMap
  • hackerrank javascript
  • hackerrank solution
  • repeat()
  • 알고리즘
  • easy algorithm
  • code refactoring
  • Javascript Algorithm
  • math.abs
  • 프로그래머스
  • 프로그래머스 알고리즘
  • hackerrank javascript solution
  • compareTo()
  • ... in Javascript
  • C++
  • easy javascript algorithm
  • string class in java
  • 프로그래머스 알고리즘문제
  • HackerRank Algorithm
more
«   2026/02   »
일 월 화 수 목 금 토
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
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바