나를 위한 개발기록
javascript map() 리팩토링
미프프
2023. 3. 5. 01:31
const removeNewNotification = () => notifiactions.map((notification) => {
return { ...notification, newNotification: false }
})
notifiactions 배열의 모든 요소에 대해 새로운 알림(newNotification)을 false로 설정하는 함수다.
이 함수를 더 간단하게 리팩터링하고 싶다.
화살표 함수 축약를 해보겠다.
const removeNewNotification = () => notifiactions.map(notification => ({ ...notification, newNotification: false }))