Skip to content

Instantly share code, notes, and snippets.

@valeriocs
Last active December 13, 2018 19:53
Show Gist options
  • Save valeriocs/d693d0494ceea0c5517ef50d46570375 to your computer and use it in GitHub Desktop.
Save valeriocs/d693d0494ceea0c5517ef50d46570375 to your computer and use it in GitHub Desktop.
Function to remove object from array if receive duplicate.
notAgain(obj) {
const removeHandler = this.array.filter(item => item === obj)
if (removeHandler.length) {
this.array = this.array.filter(item => item !== obj)
return
}
this.array.push(obj)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment