Created
August 8, 2018 06:16
-
-
Save 73nko/809924d6234341b2889b0ed4b622056f to your computer and use it in GitHub Desktop.
Function to remove ducplicates from array using reduce.
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
Array.prototype.removeDuplicates = function(){ | |
return this.reduce((result,nextItem)=>result.includes(nextItem) ? result : result.concat(nextItem),[]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment