Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is the object I created:

let myObject = {

  "ircEvent": "PRIVMSG",

  "method": "newURI",

  "regex": "^http://.*"

};

I want to know how to remove the property regex to end up with new myObject as follows?

1 Answer

0 votes
by (19.7k points)

You can remove the property from an object like below:

delete myObject.regex;

// or,

delete myObject['regex'];

// or,

var prop = "regex";

delete myObject[prop];

Interested in Java? Check out this Java Certification by Intellipaat.  

Related questions

0 votes
1 answer
0 votes
1 answer
asked Apr 14, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer
0 votes
0 answers

Browse Categories

...