ScanSkill

delete

The delete operator is used to remove a property from an object.

Syntax

delete object.propertyName

Example

const user = {
  name: "ScanSkill",
  uuid: "9ccab4ca-445d-4a5c-96d4-a2011fb04888",
}

delete user.number; // non existing property, doesn't throw error

delete user.uuid;
console.log(user); // Prints: { name: 'ScanSkill' }

console.log(delete user.name) // Prints: true

The delete operator deletes the matching property selected from an object, it returns true if the property is found and deleted, and false when not found.