Skip to main content

Don't use "delete" to remove property from the object

Medium
TypescriptJavaScript

Because you mutate the original object

Examples

Example 1:

Negative

Incorrect implementation that violates the practice.

const person = {
firstName: 'John',
lastName: 'Test',
gender: "abc"
}

delete person.gender