Instantly share code, notes, and snippets.

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

This comment has been minimized.

Copy link

anuja-cci 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment