const array1 = [
{id: 1, Q_type: "AL"},
{id: 2, Q_type: "BL"},
{id: 3, Q_type: "CL"},
{id: 4, Q_type: "DL"}
]
const array2 = [
{id: 2, Q_type: "BL"},
{id: 3, Q_type: "CL"},
{id: 4, Q_type: "DL"}
]
const arrAfterComparison = array1.filter(val => !array2.includes(val))
I am trying to compare array1 and array2 and getting the object which is not present in both of these arrays
Expected output
arrAfterComparison = [{id:1,Q_type:"AL"}]
[{id:4,Q_type:"AL"}]or[{id:1,Q_type:"AL"}]?[{id:1,Q_type:"AL"}]