Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to delete duplicate elements in an array in javascript

//Other Mathod using Foreach and includes
let chars = ['A', 'B', 'A', 'C', 'B'];

let uniqueChars = [];
chars.forEach((c) => {
    if (!uniqueChars.includes(c)) {
        uniqueChars.push(c);
    }
});

console.log(uniqueChars);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #delete #duplicate #elements #array #javascript
ADD COMMENT
Topic
Name
3+4 =