An example will speak for itself :
Array of Object :
[{
userId: 'ab4e3870-287e-11e7-b5a1-abb6183e9866',
email: '[email protected]'
},{
userId: 'ae149220-2883-11e7-bbf9-1fb134f2b4ad',
email: '[email protected]'
}]
Object
{
'ab4e3870-287e-11e7-b5a1-abb6183e9866': { name: 'john', roles: 'detective'},
'ae149220-2883-11e7-bbf9-1fb134f2b4ad': { name: 'james', roles: 'plumber'},
}
The result i'd like would be :
[{
userId: 'ab4e3870-287e-11e7-b5a1-abb6183e9866',
email: '[email protected]',
name: 'john',
roles: 'detective'
},{
userId: 'ae149220-2883-11e7-bbf9-1fb134f2b4ad',
email: '[email protected]',
name: 'james',
roles: 'plumber'
}]
So basically, the value of the key that match the userId in Object is added to that object in the array.
Is there some simple way I don't see to do that? Without external libraries in ES6?