Answers for "javascript to remove duplicates from an array"

48

js delete duplicates from array

const names = ['John', 'Paul', 'George', 'Ringo', 'John'];

let unique = [...new Set(names)];
console.log(unique); // 'John', 'Paul', 'George', 'Ringo'
Posted by: Guest on March-11-2020
9

javascript remove duplicates from array

unique = [...new Set(arr)];   // where arr contains duplicate elements
Posted by: Guest on July-03-2020
3

remove duplicates from array

let chars = ['A', 'B', 'A', 'C', 'B'];
let uniqueChars = [...new Set(chars)];

console.log(uniqueChars);

output:
[ 'A', 'B', 'C' ]
Posted by: Guest on November-26-2020
2

javascript to remove duplicates from an array

uniqueArray = a.filter(function(item, pos) {
    return a.indexOf(item) == pos; 
})
Posted by: Guest on October-22-2020
0

remove duplicate array es6

let a = [10,20,30,10,30];
let b = a.filter((item,index) => a.indexOf(item) === index);
console.log(b);
Posted by: Guest on November-23-2020
0

javascript to remove duplicates from an array

uniqueArray = a.filter(function(item, pos) {
    return a.indexOf(item) == pos;
})
Posted by: Guest on October-22-2020

Code answers related to "javascript to remove duplicates from an array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language