var arr=[ {"id":"1","title":"aaa"}, {"id":"2","title":"bbb"}, ] var obj={"id":"2","title":"bbb"}; if(JSON.stringify(arr).indexOf(JSON.stringify(obj)) === -1){ arr.push(obj) }else{ arr.map((item,i)=>{ if(item.id==obj.id){ arr.splice(i,1); } }) }