removing duplicates in array javascript
let arr = [1,2,3,1,1,1,4,5] let filtered = arr.filter((item,index) => arr.indexOf(item) === index) console.log(filtered) // [1,2,3,4,5]
js delete duplicates from array
const names = ['John', 'Paul', 'George', 'Ringo', 'John']; let unique = [...new Set(names)]; console.log(unique); // 'John', 'Paul', 'George', 'Ringo'
remove all duplicates from an Array
const removeDuplicates = arr => [...new Set(arr)];
Source: dev.to
javascript remove duplicates from array
unique = [...new Set(arr)]; // where arr contains duplicate elements
completely remove duplicate element from the array
var array = [1, 2, 3, 4, 4, 5, 5], result = array.filter(function (v, _, a) { return a.indexOf(v) === a.lastIndexOf(v); }); console.log(result); // [1, 2, 3]
Source: stackoverflow.com
remove duplicate values from array
uniqueArray = a.filter(function(item, pos) { return a.indexOf(item) == pos; })
Source: stackoverflow.com