The most direct way to remove a property from a JavaScript object is the delete operator, but it isn’t the only option. Depending on whether you want to modify the original object or create a new one without the property, JavaScript gives you a few different approaches.
Using the delete Operator
The delete operator removes a property from an object, and if that property’s value was itself an object with no other references, JavaScript eventually releases it automatically. It works on both dot notation and bracket notation:
const employee = {
firstName: "Maria",
lastName: "Sanchez",
};
console.log(employee.firstName); // "Maria"
delete employee.firstName;
console.log(employee.firstName); // undefined
This is the most direct way to remove a property, but it comes with caveats developers should be aware of. Notably, it modifies the object directly rather than creating a copy. It’s also worth knowing its limits — delete doesn’t affect the object’s prototype chain, so if a property exists there instead of directly on the object, it remains accessible even after deletion.
Bracket notation works the same way and is useful when the property name is stored in a variable:
let blog = { name: "Wisdom Geek", author: "Saransh Kataria" };
const propToBeDeleted = "author";
delete blog[propToBeDeleted];
console.log(blog); // { name: "Wisdom Geek" }
Using Reflect.deleteProperty
Reflect.deleteProperty does the same job as delete but through a method call instead of an operator, which some developers find cleaner for programmatic use:
const user = { name: "Alice", age: 30, email: "alice@example.com" };
Reflect.deleteProperty(user, 'age');
console.log(user); // { name: 'Alice', email: 'alice@example.com' }
This method works similarly to the delete operator but offers a more standardized way to remove properties, returning a Boolean indicating whether the deletion succeeded. That predictable return value makes it easier to check success or failure in your code compared to relying on delete’s own return behavior.
Using Destructuring and Rest Syntax
If you want to avoid mutating the original object, destructuring with rest syntax creates a new object that leaves out the property you don’t want:
let obj = { name: "Rohit", age: 24, city: "Noida" };
const { age, ...obj1 } = obj;
console.log(obj1); // { name: 'Rohit', city: 'Noida' }
This syntax extracts the unwanted property into its own variable and assigns everything else to a new object, leaving the original object unchanged. This is generally considered the immutable way to remove a property, as opposed to delete’s mutable approach.
Which Method Should You Use
- Use
delete when you’re fine mutating the original object and just need a quick, direct removal.
- Use
Reflect.deleteProperty when you want a clear success/failure result, particularly in code that checks whether the operation worked.
- Use destructuring with rest syntax when immutability matters — for example, before sending cleaned-up data to an API or a client, since this is a common need when processing API data or scrubbing sensitive fields before a response goes out.
Common Mistakes to Avoid
- Assuming
delete removes inherited properties — it only affects properties that exist directly on the object.
- Using
delete in performance-sensitive loops without testing impact, since it can affect how JavaScript engines optimize object shapes.
- Forgetting that
delete mutates the original object, which can cause unexpected side effects if other code still holds a reference to it.
Join The Discussion
Which method do you reach for most often when removing properties from objects — delete, Reflect.deleteProperty, or destructuring? Share how your choice changes depending on whether you’re mutating state directly or working with immutable data patterns, and if you’ve run into any gotchas with prototype chains or performance along the way, that’d be worth hearing about too.