Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Remove a Property from an Object JavaScript</title> </head> <body> <script> var person = { name: "Harry", age: 16, gender: "Male" }; // Deleting a property completely delete person.age; console.log(person.age); // Prints: undefined console.log(person); // Prints: {name: "Harry", gender: "Male"} // Setting the property value to undefined person.gender = undefined; console.log(person.gender); // Prints: undefined console.log(person); // Prints: {name: "Harry", gender: undefined} </script> <p><strong>Note:</strong> Please check out the browser console by pressing the Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (Mac) keys on the keyboard.</p> </body> </html>