Created
February 21, 2020 06:42
-
-
Save amkurian/995e689b4a14ff15a4b59cd11c76f18d 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 intersectionBy = (a, b, fn) => { | |
const s = new Set(b.map(fn)); | |
return a.filter(x => s.has(fn(x))); | |
}; | |
intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [2.1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment