Last active
November 18, 2019 00:27
-
-
Save nrkn/b2220a49daf90a2bd6582bc830153fb0 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
const intersectObjHash = ( a, b ) => { | |
const hash = {} | |
for ( let i = 0; i < b.length; i++ ) { | |
hash[ b[ i ] ] = true | |
} | |
return a.filter( el => hash[ el ] ) | |
} |
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
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