_ = require('lodash');
var firstArray = [
{
'name': 'MyGroup',
'description': null,
'items': [
{
'_id': 'uStqrALmwWCdyzBnc',
'type': 'endpoints'
},
{
'_id': 'tpCSiT65R5PHmQ2yn',
'type': 'endpoints'
}
],
'_id': '8phfSHKLt9c5SB2YM'
}
];
var secondArray= [
{
'name': 'MyGroup',
'description': null,
'items': [
{
'_id': 'GET_test',
'type': 'endpoints'
}
]
}
];
console.log(JSON.stringify(_.merge(firstArray, secondArray), null, 2));
The resulting output is:
[
{
"name": "MyGroup",
"description": null,
"items": [
{
"_id": "GET_test",
"type": "endpoints"
},
{
"_id": "tpCSiT65R5PHmQ2yn",
"type": "endpoints"
}
],
"_id": "8phfSHKLt9c5SB2YM"
}
]
When reversing the order of arrays, the merging only produces the contents of the second array. This raises questions about why the merge is partial and not complete. Is this a logical outcome or possibly a bug?