Skip to content

Instantly share code, notes, and snippets.

@bush
Created December 5, 2021 22:50
Show Gist options
  • Save bush/4ea13a0bbe3545c1fdfce3570ca39301 to your computer and use it in GitHub Desktop.
Save bush/4ea13a0bbe3545c1fdfce3570ca39301 to your computer and use it in GitHub Desktop.
Array.prototype.diff = function(arr2) { return this.filter(x => !arr2. includes(x)); }
let arr1 = ['release','layer-1','bsp-1']
console.log(`OG list: ${arr1}`);
let arr2 = ['release','layer-2','bsp-1']
console.log(`New list: ${arr2}`);
console.log(`Remove list: ${arr1.diff(arr2)}`);
let newDl = arr2.diff(arr1);
console.log(`New downlowd list: ${newDl}`);
console.log(`Refresh list: ${arr2.diff(newDl)}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment