-1
My question is this, how can I make a matrix that has 3 objects become a single object ? According to the print below, the matrix is bringing me 3 objects, however I need to assemble a single object with the value of each matrix, I have researched something like reduce, but I could not achieve success. Here is my code :
//"ITEMS" é um FirebaseListObservable que transformo em um array
//javascript
//dadosPontoFuncionario é o meu array javascript, que está retornando
//o que está no console, é ele que preciso que vire um único objeto
this.items.subscribe( data => {
this.dadosPontoFuncionario = data;
console.log(this.dadosPontoFuncionario);
})
What array? you don’t have an object array?
– Leandro Angelo
How you will treat if there are two identical keys when joining objects in your array?
– fernandosavio
I have an array of objects, but I would like to turn it into a single object you understand, unite the 3 objects into one, I don’t even know if it has to do this. It depends on which key he considers, the $key is unique, but I have two other types of keys that are repeated on each object of that.
– Diego Estacho
I still can’t understand... you generate a single object consolidating all the properties of all objects in the array? or create a replica on a single object where each object would be a property? Ex.:
{ item1: {}, item2:{} ...}
– Leandro Angelo
Generate a single object by consolidating all properties of all objects in the array. For you to understand better, it is a point registration application. So each object corresponds to a recorded point, I have the starting point, interval point, end of hours point. I need to show them on the screen for the user, but to organize better, I wanted to join the 3 objects, so I can have access to information of the 3 at the same time and I can show this information on the screen. If not I have to show the separate objects in the view.
– Diego Estacho