javascipt .delete code example

Example 1: javascript delete key from object

let person = {
  firstname: 'John',
  lastname: 'Doe'
}

console.log(person.firstname);
// expected output: "John"

delete person.firstname;

console.log(person.firstname);
// expected output: undefined

Example 2: js Property Assignment delete

delete objectName['Property Name'];
delete objectName.propName;

Example 3: delete js

let monTableauAssociatif = {
     'prenom' : 'Mark' ,
     'nom'    : 'Zuckerberg' , 
     'poste'  : 'Pdg de Facebook',

 } ;
 delete(monTableauAssociatif.poste)
 console.log(monTableauAssociatif) ;