create object javascript code example
Example 1: Build JavaScript Objects
var myDog = {
name: "gozi",
legs: 4,
tails: 1,
friends: ["Ted", "Fred"]
};
Example 2: javascript object
var person = {
first_name : "Marty",
last_name : "Mcfly",
born : 1968,
died : 1933,
lovers: ["Jennifer Parker","Baines McFly"]
};
Example 3: object object javascript
person = {
'name':'john smith'
'age':41
};
console.log(person);
console.log(JSON.stringify(person));
Example 4: creating an object javascript
let obj = {
name:"value",
num: 123,
foo: function(){}
}
Example 5: create object javascript
const object = {
something: "something";
}
Example 6: create object javascript
let voleur = {
action : () =>console.log ('Coup de dague fatal') ,
crie : ('pour la horde!!!!') ,
coupfatal :()=> console.log ('coup dans le dos')
}
voleur.action() ;
voleur.coupfatal() ;
console.log(voleur.crie) ;