creating objects in js code example

Example 1: Build JavaScript Objects

var myDog = {
  name: "gozi",
  legs: 4,
  tails: 1,
  friends: ["Ted", "Fred"]
};

Example 2: creating an object javascript

let obj = {
// fields
  name:"value",
  num: 123,
//methods
  foo: function(){}
  
}

Example 3: object literal javascript

// Object literals are defined using the following syntax rules:
// A colon separates property name from value.
// A comma separates each name-value pair from the next.
// There should be no comma after the last name-value pair.

// If any of the syntax rules are broken, such as a missing comma or colon or curly brace,
// an error will be thrown.

var myObject = {
    sProp: 'some string value',
    numProp: 2,
    bProp: false
};

Example 4: how to create a object in javascript

var a = {
name: "aakash",
  age:30
}

Example 5: 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) ;