[
{ id: "5jq", url: "https://cdn2.thecatapi.com/images/5jq.jpg", width: 320 },
{ id: "5qj", url: "https://cdn2.thecatapi.com/images/5qj.jpg", width: 480 }
]
Array.prototype.push.apply(
arr,
newArr.filter(n => !arr.some(m => m.id === n.id))
);
arr.splice(0, arr.length, ...arr
.concat(newArr)
.reduce((acc, n) => acc.set(n.id, acc.get(n.id) ?? n), new Map)
.values()
);
newArr.forEach(function(n) {
this.has(n.id) || (arr[arr.length] = n);
}, new Set(arr.map(n => n.id)));