Hello, thanks for your answers and comments. I come to you for the following, I have the following array of objects:
const customCatalogs = [
customTableValues = [
{id: 2, puestos: "Recursos Humanos", visible: "puesto dos"},
{id: 1, puestos: "Dearrollador", visible: "puesto uno"}
],
customEmployeeValue = null
];
I want to add to customEmployeeValue the following object:
{
id: 1,
puestos: "Dearrollador",
visible: "puesto uno"
}
But I am trying to add this object inside a key named value, I want to achieve this:
const customCatalogs = [
customTableValues = [
{id: 2, puestos: "Recursos Humanos", visible: "puesto dos"},
{id: 1, puestos: "Dearrollador", visible: "puesto uno"}
],
customEmployeeValue = {
value: {
id: 1,
puestos: "Dearrollador",
visible: "puesto uno"
}
}
];
Where the object I want to add has the key value .
I am trying as follows:
const payload = {
id: 1,
puestos: "Dearrollador",
visible: "puesto uno"
};
const customCatalogs = [
customTableValues = [
{id: 2, puestos: "Recursos Humanos", visible: "puesto dos"},
{id: 1, puestos: "Dearrollador", visible: "puesto uno"}
],
customEmployeeValue = null
];
customCatalogs.customEmployeeValue = payload;
console.log(customCatalogs)
Thank you all for your answers and comments.
The problem is that the structure is poorly defined, based on your idea of handling an array of objects, you would have to fix the structure and access index 1 of the array to be able to access the object whose key is "customEmployeeValue".
You could do something like this:
Another way is not to use an array and do everything with an object. As follows: