Skip to content

Instantly share code, notes, and snippets.

@rafaelmaeuer
Created May 24, 2023 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelmaeuer/daf75275a53bacf561002c71f1788d88 to your computer and use it in GitHub Desktop.
Save rafaelmaeuer/daf75275a53bacf561002c71f1788d88 to your computer and use it in GitHub Desktop.
var arr1 = [
{
"prop1": "value1",
"prop2": "value2",
},
{
"prop1": "value3",
"prop2": "value4",
},
{
"prop1": "value5",
"prop2": "value6",
},
];
var arr2 = ['value1','value3', 'newValue'];
// finds all the elements of arr2 that are not in arr1
arr2.filter(
val => !arr1.find( arr1Obj => arr1Obj.prop1 === val)
); // outputs "newValue"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment