I have following 2 arrays.
const array1 = [
{name: "V1", year: "2018", isDefault: false},
{name: "V2", year: "2018", isDefault: false},
{name: "V3", year: "2018", isDefault: false},
{name: "V4", year: "2018", isDefault: false},
{name: "V1", year: "2019", isDefault: true}
];
and
const array2 = [
{name: "V1", year: "2018", isDefault: false},
{name: "V2", year: "2018", isDefault: false},
{name: "V3", year: "2018", isDefault: false},
{name: "V4", year: "2018", isDefault: false},
{name: "V1", year: "2020", isDefault: true}
];
I want to get a resulting array which has all the items from array1 and array2 but having common items only once based on name and year (Based on combination of 2 keys). I have to get the resulting array as follows:
const array = [
{name: "V1", year: "2018", isDefault: false},
{name: "V2", year: "2018", isDefault: false},
{name: "V3", year: "2018", isDefault: false},
{name: "V4", year: "2018", isDefault: false},
{name: "V1", year: "2019", isDefault: true},
{name: "V1", year: "2020", isDefault: true}
];
Please help me how to get this in javascript?