Total :
/ Today :
/ Yesterday :
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
- ES6
- terminationGracePeriodSeconds
- zombie-hit apartment
- post
- json
- javascript
- Java
- ajax
- html
- topologySpreadConstraints
- chartjs
- ssh
- mongodb
- 영화예매
- mysql
- spread operator
- MySQL Error
- spring
- git
- node.js
- Kubernetes
- AWS
- 인생이재밌다
- AWS RDS
- Get
- jsp
- sessionStorage
- AWS Route53
- Bootstrap
- 예매로직
Archives
- Today
- Total
jongviet
Oct 17, 2021 - 불변성!! 본문
*10월17일
-불변성 지키면서 객체 수정 / 병합 / 제거
const obj= {
a: 1,
b: 2
};
const newObj= {
...object, //spread operator로 복사 후, 변경원하는 값만 변경
b: 3
};
const schedules= [
{
id: 1,
whatDay: 'Mon',
isDone: true
},
{
id: 2,
whatDay: 'Wed',
isDone: false
}
];
const merged= schedules.concat({ // concat을 활용한 병합
id: 3,
whatDay: 'days',
isDone: false
});
const filtered = schedules.filter(schedule=> schedule.id !== 3); //3번 스케쥴만 제외
const modified = schedules.map(schedule=> schedule.id === 3 ? { ...schedule, isDone: !schedule.isDone,} : schedule); //map을 활용한 수정
'javascript & typescript' 카테고리의 다른 글
| Feb 26, 2023 - promise.all & for await of (0) | 2023.02.26 |
|---|---|
| March 6, 2022 - typescript (0) | 2022.03.06 |
| Oct 10, 2021 - spread operator (0) | 2021.10.10 |
| Sep 30, 2021 - 객체 형태 배열 string화 하기 (1) | 2021.09.30 |
| Sep 25, 2021 - for await of (0) | 2021.09.25 |
Comments