The delete keyword entirely removes a property from an object. The use of delete is discouraged because it can lead to fatal errors in an application by changing the data model.

Things to keep in mind:

  • You can check whether or not an object has a property by calling the hasOwnProperty(prop) method on the object.
  • delete will return true if it successfully deleted a property. It was also return true if you try to delete a property that already does not exist.
  • You cannot use delete to delete an entire object.