how to create new object in javascript code example
Example 1: object inside object javascript
var obj = {
prop1: 5,
obj2: {
prop1: [3, 6, 3],
prop2: 74,
prop3: {
str: "Hello World"
}
}
};
console.log(obj.obj2.prop3.str);
Example 2: creating an object javascript
let obj = {
name:"value",
num: 123,
foo: function(){}
}
Example 3: create object javascript
const object = {
something: "something";
}
Example 4: how to create a object in javascript
var a = {
name: "aakash",
age:30
}
Example 5: js create new object
let bike = { name: 'SuperSport', maker:'Ducati', start: function() { console.log('Starting the engine...'); }};bike.start();
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) ;