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