how to add a property to an objects in javascript code example
Example 1: how to a property from a JavaScript object
delete myObject.regex;
// or,
delete myObject['regex'];
// or,
var prop = "regex";
delete myObject[prop];
/** Demo */
var myObject = {
"ircEvent": "PRIVMSG",
"method": "newURI",
"regex": "^http://.*"
};
delete myObject.regex;
console.log(myObject);
Example 2: add property with value in js
var myObject = {
sProp: 'some string value',
numProp: 2,
bProp: false
};