Step 1: Understanding Object Properties in JavaScript:
A JavaScript object is a standalone entity with properties and types. A property is an association between a name (or key) and a value. For example:
var person = {
name: "Alice",
age: 25
};
Step 2: Analyzing the delete Operator:
The JavaScript delete operator removes a property from an object. If the property's value is an object and there are no other references to it, the memory is eventually released automatically through garbage collection.
• Syntax: delete object.property or delete object['property']
• Return Value: Returns true if the property was successfully deleted or if the property does not exist. It only returns false if the property is non-configurable (e.g., built-in object properties configured via Object.defineProperty).
Step 3: Evaluating the Options:
• (A) {remove age is syntax-error code. remove is not an operator in JS.
• (B) {clear person.age is invalid; clear is not a native operator for object properties.
• (C) {delete person.age is the syntactically correct expression in JS.
• (D) {person.remove(age) assumes there is a prototype method called remove() which is not standard.