This post will discuss how to remove a property from an object in JavaScript.

1. Using Delete Operator

The delete operator removes a given property from an object, returning true or false as appropriate on success and failure.

Download  Run Code

2. Using Spread operator

With ES6, you can use the object literal destructuring assignment to unpack properties from objects into distinct variables. This is demonstrated below:

Download  Run Code

 
Note this will create a new object. You can even do this without a declaration by using parentheses ( … ) around the assignment statement.

Download  Run Code

3. Using Reflect.deleteProperty() function

The Reflect.deleteProperty() method is used to delete a property on an object. It is identical to the delete operator.

Download  Run Code

4. Using Underscore/Lodash Library

If you’re already using the Underscore or Lodash library, consider using the _.omit method. It creates a copy of the object without the specified property.

Download Code

That’s all about removing a property from an object in JavaScript.