Answers for "remove duplicates strings with filter in js"

2

delete duplicates array of strings Javascript

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

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

javascript array remove duplicates

function toUniqueArray(a){
    var newArr = [];
    for (var i = 0; i < a.length; i++) {
        if (newArr.indexOf(a[i]) === -1) {
            newArr.push(a[i]);
        }
    }
  return newArr;
}
var colors = ["red","red","green","green","green"];
var colorsUnique=toUniqueArray(colors); // ["red","green"]
Posted by: Guest on July-23-2019

Code answers related to "remove duplicates strings with filter in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language