Skip to content

Instantly share code, notes, and snippets.

@erikpantzar
Last active October 4, 2017 15:36
Show Gist options
  • Save erikpantzar/410556d07f7bea26afa54028ae98d275 to your computer and use it in GitHub Desktop.
Save erikpantzar/410556d07f7bea26afa54028ae98d275 to your computer and use it in GitHub Desktop.
const o = ['abc', 'hejhej', 'defg'];
const n = ['hejhej', 'defg', 'JOHAN'];
const getDiff = (current, neu) => {
return neu.filter((item, index) => {
if(current.indexOf(item) === -1) {
return item
}
})
}
console.log(getDiff(o, n)) // returns ['JOHAN']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment