what is an object literal in javascript code example
Example 1: creating an object javascript
let obj = {
name:"value",
num: 123,
foo: function(){}
}
Example 2: object literal javascript
var myObject = {
sProp: 'some string value',
numProp: 2,
bProp: false
};
Example 3: literal object js
var car = {type:"Fiat", model:"500", color:"white"};
Example 4: javascript object literal and json
var obj = {foo: 42};
var json = '{"foo": 452}';
Example 5: how to create an object in javascript
const person = {
name: 'Anthony',
age: 32,
city: 'Los Angeles',
occupation: 'Software Developer',
skills: ['React','JavaScript','HTML','CSS']
};
const message = `Hi, I'm ${person.name}. I live in ${person.city}.`;
console.log(message);