Skip to content

Instantly share code, notes, and snippets.

@Stefanacef
Created November 1, 2021 14:07
Show Gist options
  • Save Stefanacef/778d14b787d3dc028e3bffa29fb3eeb4 to your computer and use it in GitHub Desktop.
Save Stefanacef/778d14b787d3dc028e3bffa29fb3eeb4 to your computer and use it in GitHub Desktop.
How to filter an array and an array of objects | how to filter two arrays
const arr=['one','two','three','four']
const verif=[
{id:'one'},
{id:'aaaa'},
{id:'two'},
{id:'bbbb'},
{id:'three'},
{id:'four'},
]
verif.filter((el)=>{
arr.indexOf(el.id)!=-1 ? console.log(el.id) : null
})
// one two three four
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment