Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Array.prototype.removeDuplicates = function(){
return this.reduce((result,nextItem)=>result.includes(nextItem) ? result : result.concat(nextItem),[]);
}
@anuja-cci

This comment has been minimized.

Copy link

commented Aug 13, 2018

Very beautiful use of reduce function, but in the above example, the above function does not work for any of the internet explorers as "includes" function is not supported by internet explorer

@kubarium

This comment has been minimized.

Copy link
Owner Author

commented Feb 8, 2019

Very beautiful use of reduce function, but in the above example, the above function does not work for any of the internet explorers as "includes" function is not supported by internet explorer

You could, alternatively, use indexOf instead of includes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.