what is an object literal code example
Example 1: creating an object javascript
let obj = {
name:"value",
num: 123,
foo: function(){}
}
Example 2: js objects
const dog = {
name: "Rusty",
breed: "unknown",
isAlive: false,
age: 7
}
dog.age;
dog["age"];
dog.breed = "mutt";
dog["age"] = 8;
Example 3: object literal javascript
var myObject = {
sProp: 'some string value',
numProp: 2,
bProp: false
};
Example 4: 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 5: literal object js
var car = {type:"Fiat", model:"500", color:"white"};