Skip to content

Instantly share code, notes, and snippets.

@roshanca roshanca/unique.js
Last active Jun 22, 2018

What would you like to do?
unique array
const arr = ['aaa', 'bbb', 'aaa', '111'];
const uniqueArr = arr.filter((item, index) => {
return arr.indexOf(item) === index;
console.log(uniqueArr); // ['aaa', 'bbb', '111']
const simpleUnique = function(arr) {
return [ Set(arr)]
console.log(simpleUnique(arr)); // ["aaa", "bbb", "111"]
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.