1. 객체 복사
- Object.assign({},배열)
- {...배열}
2. for문 활용
- 중간에 내용을 바꾸어서 return할 수도 있다.
3. reduce 활용
- reduce 함수를 이용하여 배열을 순환 후 Object로 변경
- array.reduce(누산기, 현재값, 현재 인덱스, {초기값} )
참조 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
https://codingcoding.tistory.com/1244
'리액트,자바스크립트' 카테고리의 다른 글
JavaScript Object Methods (0) | 2021.08.02 |
---|---|
react-redux (0) | 2020.07.05 |
React-redux.md (0) | 2020.07.05 |
React 상태관리 (Context, Redux) (0) | 2020.06.16 |
React Hooks -1 (0) | 2020.06.05 |