I have an array of objects like this:
array1 = [
{field: 'username', display: 'username', hide: true},
{field: 'age', display: 'Age', hide: true},
{field: 'height', display: 'Height', hide: true}
]
Then I have array2:
array2 = [
{field: 'username', display: 'username 123', hide: false},
{field: 'age', hide: false}
]
I want to merge these two arrays by their field i.e. the final result should be:
array3 = [
{field: 'username', display: 'username 123', hide: false},
{field: 'age', display: 'Age', hide: false},
{field: 'height', display: 'Height', hide: true}
]
I tried var newObj = _.extend(array1, array2);
but it didn't give me what I want.