DekGenius.com
JAVASCRIPT
remove duplicates from array
let chars = ['A', 'B', 'A', 'C', 'B'];
let uniqueChars = [...new Set(chars)];
console.log(uniqueChars);
output:
[ 'A', 'B', 'C' ]
remove all duplicates from an Array
const removeDuplicates = arr => [...new Set(arr)];
remove duplicates array.filter
// removeDuplicates ES6
const uniqueArray = oldArray.filter((item, index, self) => self.indexOf(item) === index);
remove duplicates from array
// Use to remove duplicate elements from the array
const numbers = [2,3,4,4,2,3,3,4,4,5,5,6,6,7,5,32,3,4,5]
console.log([...new Set(numbers)])
// [2, 3, 4, 5, 6, 7, 32]
Remove Duplicates in an Array
const removeDuplicates = (arr) => [...new Set(arr)]
removeDuplicates([31, 56, 12, 31, 45, 12, 31])
//[ 31, 56, 12, 45 ]
remove duplicates in array
uniq = [...new Set(array)];
or
uniqueArray = a.filter(function(item, pos) {
return a.indexOf(item) == pos;
})
remove duplicates from array
$array = array(1, 2, 2, 3);
$array = array_unique($array); // Array is now (1, 2, 3)
remove duplicate Array
let Arr = [1,2,2,2,3,4,4,5,6,6];
//way1
let unique = [...new Set(Arr)];
console.log(unique);
//way2
function removeDuplicate (arr){
return arr.filter((item,index)=> arr.indexOf(item) === index);
}
removeDuplicate(Arr);
Remove Array Duplicate
const removeDuplicates = (arr) => [...new Set(arr)];
console.log(removeDuplicates([1, 2, 3, 3, 4, 4, 5, 5, 6]));
// Result: [ 1, 2, 3, 4, 5, 6 ]
Remove duplicates from array
$uniqueme = array();
foreach ($array as $key => $value) {
$uniqueme[$value] = $key;
}
$final = array();
foreach ($uniqueme as $key => $value) {
$final[] = $key;
}
© 2022 Copyright:
DekGenius.com