Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

compare and filter two array of object

array1 = [{path: "hello"}, {path: "world"}];
array2 = [{path: "hello"}, {path: "hahah", text: "dsdsds"}];

//comparing array1 and array2 and returning unmatced from array1

Object.keys(array1)
  .filter((val, index) => array1[index].path !== array2[index].path)
  .map((val, index) => array1[index]);

// output
//[{"path": "world"}]
Comment

PREVIOUS NEXT
Code Example
Javascript :: react native socket io 
Javascript :: javascript is a string numeric 
Javascript :: FullScreen Image By OnClick Jquery 
Javascript :: js get day month year 
Javascript :: js int to alphabet 
Javascript :: settime out with promise 
Javascript :: lodash remove undefined values from array 
Javascript :: req.url 
Javascript :: laravel query json 
Javascript :: chart js x axis start at 0 
Javascript :: only allow numbers in text input in js 
Javascript :: properly import mat icon angular 10 
Javascript :: redux devtools extension npm 
Javascript :: jquery check if type is checkbox 
Javascript :: how to get datetime in nodejs 
Javascript :: how to set current date and time in jquery datetime-local 
Javascript :: push-method-in-react-hooks-usestate 
Javascript :: react js materilize 
Javascript :: check if string matches regex js 
Javascript :: how to fetch the all input element id value 
Javascript :: prototype pollution 
Javascript :: Shuffle a Sting in JavaScript 
Javascript :: javascript json parse 
Javascript :: Get the Status Code of a Fetch HTTP Response 
Javascript :: for of array javascript 
Javascript :: How To Set Opacity of a View In React Native 
Javascript :: if checkbox is checked open modal popup 
Javascript :: js find space in string 
Javascript :: refresh after delete in express 
Javascript :: react scroll reset in component 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =