Created
July 6, 2021 05:50
-
-
Save sweeneyapps/3db43c76a81d0f9cb65be017806997d4 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
let _ = require('lodash'); | |
let arr = [1, 5, 10]; | |
let arr2 = [1, 4, 10]; | |
let result = _.difference(arr, arr2); // 5 | |
let result2 = _.difference(arr2, arr); // 4 | |
let diffTogether = [...result, ...result2]; // [ 5, 4 ] | |
let newSet = new Set([...arr, ...arr2]); // Set(1, 4, 5, 10) | |
let matched = _.difference([...newSet], diffTogether); // [ 1, 10 ] | |
console.log(matched); // [ 1, 10 ] | |
console.log(diffTogether); // [ 5, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment