delete

개념

remove prop from an object
삭제 후, 복구 안됨

const obj = { a: 1, b: 2 }

delete obj.a // Removing the 'a' property from the object
console.log(myObject) // Output: { b: 2 }

주의

delete로 지우면 메모리에서 완전히 지워지는 것이기 때문에,
지우려는 prop이 다른 곳에 사용하고 있다면 위험

prop을 지울 때 적절한 방법

destructure syntax를 이용해보자

const obj = { a: 1, b: 2, c: 3 }
const { a, ...rest } = obj
console.log(rest) // Output: { b: 2, c: 3 }

Reference

https://hardiquedasore.medium.com/avoid-delete-keyword-in-javascript-to-remove-property-97ffc1fded43