Js array take more and less

a = [{id:1}, {id:2}, {id:3}]
b = [{id:1}, {id:2}, {id:4}]

how to calculate

in b that b does not have in a

according to the meaning of the question, you want to get {id: 4}] ?

that a does not exist in b.
let a = [{id:1},{id:2},{id:3}];
let b = [{id:1},{id:2},{id:4}];
let result = b.filter(el => {
    return !(a.find(item => el.id === item.id));
});
console.log(result);
// [{id: 4}]

in the same way, you can get [{id: 3}] .


take the

that b does not have in a.

1

var result = new Object();
var a=[{id:1},{id:2},{id:3}];
var b=[{id:1},{id:2},{id:4}];
var c= a.concat(b);
c.forEach(x=>(result[x.id]&&(result[x.id].countPP))||(result[x.id]=x)&&(x.count=1));
c.filter(x=>x.count==1);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdbdad-53f0f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdbdad-53f0f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?