I have two arrays of objects that represent email addresses that have a label and a value:
var original = [
{
label: 'private',
value: '[email protected]'
},
{
label: 'work',
value: '[email protected]'
}
];
var update = [
{
label: 'private',
value: '[email protected]'
},
{
label: 'school',
value: '[email protected]'
}
];
Now I want to compare and merge the two arrays by the label
field, so that the result would look like this:
var result = [
{
label: 'private',
value: '[email protected]'
},
{
label: 'work',
value: '[email protected]'
},
{
label: 'school',
value: '[email protected]'
}
]
How can I do this e.g. using lodash?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…