how to create a new object in javascript code example

Example 1: object object javascript

person = {
    'name':'john smith'
    'age':41
};

console.log(person);
//this will return [object Object]
//use
console.log(JSON.stringify(person));
//instead

Example 2: creating an object javascript

let obj = {
// fields
  name:"value",
  num: 123,
//methods
  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: how to create a object in javascript

var about = {
  name:"lanitoman",
  age:1023,
  isHeProgrammer:true
}

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) ;

Tags:

Java Example