Filter unique elements from an Array using modern JavaScript (ES6)
Today I was trying to organize some scripts, where I have many lines of text and I need to eliminate duplicate lines.
I knew that this can be done with Array.reduce() and using Set of EcmaScript6.
This is the smallest one I have ended up with:
const arr = ['Hello!', 'Utopian', 'Dev', 'Utopian', 'Author'];
const unique1 = [...new Set(arr1)]; // ['Hello!','Utopian','Dev','Author']
Last Updated on
Comments