Answers for "remove duplicate array es6"

CSS
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
1

js delete duplicates from array

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

function removeDups(names) {
  let unique = {};
  names.forEach(function(i) {
    if(!unique[i]) {
      unique[i] = true;
    }
  });
  return Object.keys(unique);
}

removeDups(names); // // 'John', 'Paul', 'George', 'Ringo'
Posted by: Guest on March-11-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
1

javascript filter array remove duplicates

// Using the Set constructor and the spread syntax:

arrayWithOnlyUniques = [...new Set(arrayWithDuplicates)]
Posted by: Guest on December-21-2020
0

remove duplicate array es6

let a = [10,20,30,10,30];
let b = [... new Set(a)];
console.log(b);
Posted by: Guest on November-23-2020
-1

remove duplicate array es6

let a = [10,20,30,50,30];
let b = a.reduce((unique,item) => unique.includes(item) ? unique: [... unique, item] ,[]); 
console.log(b);
Posted by: Guest on November-23-2020

Code answers related to "remove duplicate array es6"

Browse Popular Code Answers by Language