Last active
March 9, 2021 15:15
-
-
Save CryceTruly/824cd41234a494b63144d57a78f34287 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is how you can do it when the items in the arrays are objects. | |
The idea is to find the array of only the keys in an inner array using the map function | |
Then foreach of those check if they contain a spectific element key in the outer array. | |
const existsInBothArrays = array1.filter((element1) => | |
array2.map((element2) => element2._searchKey).includes(element1._searchKey), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment