How to fill an object object, javascript?

0

I'm trying to put together the next object

objeto: "D1": { 
            "C60": true, 
            "C80": true 
        } 

that it contains contains another object. I do it in the following way:

permisosCuponesSeleccionados["usuario"] = "D1
console.log(permisosCuponesSeleccionados);

The problem is that I always create the same object. How can I create multiple objects within that object?

    
asked by JG_GJ 26.11.2018 в 22:06
source

1 answer

1

Explaining that javascript objects are a way of saving multiple data, such as string , boolean , int , float , etc.

You can create an object called cellular , the cell phone has three or more data, some of them are color, brand, capacity.

  

The color can vary, it can be black and gray at the same time, we can   put it together in the following way:

var celular = {
  color: ['negro', 'gris'],
  marca: 'iPhone',
  capacidad: 64
}

console.log(celular)

As we can see in the object celular.color there is and more than one data, they can be more if you want.

var celular = {
  color: ['negro', 'gris'],
  marca: 'iPhone',
  capacidad: 64
}

console.log(celular.color)

But we can add more data to my object celular , we can add modelo .

var celular = {
  color: ['negro', 'gris'],
  marca: 'iPhone',
  capacidad: 64
}

celular.modelo = '6S'

console.log(celular)

In this way we modify our object by adding a new data called model, this data is a string , we can add another data that is an object ..

var celular = {
  color: ['negro', 'gris'],
  marca: 'iPhone',
  capacidad: 64
}

celular.modelo = '6S'

var aplicaciones = [
  {
    nombre: 'whatsapp',
    peso: 120,
  },
  {
    nombre: 'facebook',
    peso: 160,
  }
]

celular.aplicaciones = aplicaciones

console.log(celular)
  

In this way we add a list of objects in an object.

    
answered by 26.11.2018 в 23:09