Last active
December 13, 2018 19:53
-
-
Save valeriocs/d693d0494ceea0c5517ef50d46570375 to your computer and use it in GitHub Desktop.
Function to remove object from array if receive duplicate.
This file contains hidden or 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
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