Skip to content

Instantly share code, notes, and snippets.

@nrkn
Last active November 18, 2019 00:27
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 nrkn/b2220a49daf90a2bd6582bc830153fb0 to your computer and use it in GitHub Desktop.
Save nrkn/b2220a49daf90a2bd6582bc830153fb0 to your computer and use it in GitHub Desktop.
const intersectObjHash = ( a, b ) => {
const hash = {}
for ( let i = 0; i < b.length; i++ ) {
hash[ b[ i ] ] = true
}
return a.filter( el => hash[ el ] )
}
const intersectSetHash = ( a, b ) => {
const hash = new Set( b )
return a.filter( el => hash.has( el ) )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment