Skip to content

Instantly share code, notes, and snippets.

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