27.
How can you delete a property from an object in JavaScript?
By using the delete keyword
By setting the value of the property to null
By using the remove() method
By using the splice() method
Correct: A
To delete a property from an object in JavaScript, you can use the delete keyword followed by the name of the property. This will completely remove the property from the object. Example:
const person= {
firstname: 'John',
lastname: 'Doe',
};
console.log(person.firstname);
// output: "John"
delete person.firstname;
console.log(person.firstname);
// output: undefined