Created
July 23, 2018 18:07
-
-
Save derekedelaney/52fd438c133e3b3005a2b3dbbce65163 to your computer and use it in GitHub Desktop.
simple javascript helper functions
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
// Intersection | |
let intersection = arr1.filter(x => arr2.includes(x)); | |
// Difference | |
let difference = arr1.filter(x => !arr2.includes(x)); | |
// Symmetric Difference | |
let difference = arr1 | |
.filter(x => !arr2.includes(x)) | |
.concat(arr2.filter(x => !arr1.includes(x))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment