How to check duplicates or remove duplicates from array in JS
Copy Below Code
View As A Text File
Show Text Only
Show API
Edit Code
let strArray = [ "q", "w", "w", "w", "e", "i", "u", "r"];
let findDuplicates = (arr) =>
arr.filter((item, index) =>
{
return arr.indexOf(item) == index // this will get the first possible occurance,so all time it will be unique,
// so it will only be get once
}
)
console.log(findDuplicates(strArray)) // All duplicates