 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do we remove a property from a JavaScript object? - JavaScript
Let’s say, we have an object as follows −
const myObject = {    "ircEvent": "PRIVMSG",    "method": "newURI",    "regex": "^http://.*" }; We are required to illustrate the best way to remove the property regex to end up with new myObject?
Following is the solution −
const myObject = {    "ircEvent": "PRIVMSG",    "method": "newURI" }; The delete operator is used to remove properties from objects.
const myObject = {    "ircEvent": "PRIVMSG",    "method": "newURI",    "regex": "^http://.*" }; delete myObject['regex']; console.log(myObject.hasOwnProperty("regex")); // false The delete operator in JavaScript has a different function to that of the keyword in C and C++ −
It does not directly free memory. Instead, its sole purpose is to remove properties from objects.
Output
Following is the console output −
False
Advertisements
 