Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

filter using two array of objects

const arr1 = [{id:'1',name:'A'},{id:'2',name:'B'},{id:'3',name:'C'},{id:'4',name:'D'}];
const arr2 = [{id:'1',name:'A',state:'healthy'},{id:'3',name:'C',state:'healthy'}];
const filterByReference = (arr1, arr2) => {
   let res = [];
   res = arr1.filter(el => {
      return !arr2.find(element => {
         return element.id === el.id;
      });
   });
   return res;
}
console.log(filterByReference(arr1, arr2));
Comment

PREVIOUS NEXT
Code Example
Javascript :: remove bearer from token in node js 
Javascript :: expo create react native app 
Javascript :: document queryselector click event 
Javascript :: javascript create text file 
Javascript :: jquery change picture source 
Javascript :: get current scroll height javascript 
Javascript :: add set time out in jquery 
Javascript :: refresh page after success ajax 
Javascript :: javascript detect scroll to bottom of page 
Javascript :: javascript detect video end 
Javascript :: allow only integer or float in text fields jQuery 
Javascript :: jquery datepicker change date format 
Javascript :: div outside click event jquery 
Javascript :: TypeError: value.toLowerCase is not a function 
Javascript :: js get current date 
Javascript :: jquery on 2 events 
Javascript :: javascript appendchild at index 
Javascript :: TypeError: this.jsonEnabled is not a function 
Javascript :: datatables typeerror k is undefined 
Javascript :: jquery nearest 
Javascript :: get channel id discord js v12 
Javascript :: button click javascript 
Javascript :: js check if infinity 
Javascript :: js remove json value duplicates 
Javascript :: 11.10*15.1667 
Javascript :: Configure morgan so that it also shows the data sent in HTTP POST requests: 
Javascript :: how to add an element to the last position of an array in javascript 
Javascript :: get text of selected option in select2 jquery 
Javascript :: javascript uppercase first letter of each word 
Javascript :: get how much i scroll in jquery 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =