Last active
October 13, 2020 23:25
-
-
Save bsdahl/2175aaf2885f0a4bbc00ade99a5f5365 to your computer and use it in GitHub Desktop.
Function that will find intersecting keys for n number of object arguments.
This file contains hidden or 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
| export function intersectingKeys(...objects) { | |
| return objects | |
| .map((object) => Object.keys(object)) | |
| .sort((a, b) => a.length - b.length) | |
| .reduce((a, b) => a.filter((key) => b.includes(key))); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you find intersecting keys of n number of objects?