Created
August 8, 2018 13:06
-
-
Save israeljrs/6d641192fa80b351ad80902932344e11 to your computer and use it in GitHub Desktop.
Using Reduce to Remove Duplicates in JavaScript array
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
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