Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

Say I create an object as follows:

var myObject = { 

"ircEvent": "PRIVMSG", 

"method": "newURI", 

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

};

What is the best way to remove the property regex to end up with new myObject as follows?

var myObject = { 

"ircEvent": "PRIVMSG", 

"method": "newURI" 

};

1 Answer

0 votes
by (106k points)

To remove a property from a JavaScript object you can use delete method.

Code example:-

var myObject = { 

"ircEvent": "PRIVMSG", 

"method": "newURI", 

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

}; 

delete myObject.regex; 

console.log(myObject);

image

Related questions

0 votes
0 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...