0 votes
1 view
in Web Technology by (47.8k 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 (107k 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
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...