duplicate numbers in an array javascript
[1, 1, 2, 2, 3].filter((element, index, array) => array.indexOf(element) !== index) // [1, 2]var input = [1, 2, 3, 1, 3, 1];
var duplicates = input.reduce(function(acc, el, i, arr) {
if (arr.indexOf(el) !== i && acc.indexOf(el) < 0) acc.push(el); return acc;
}, []);
document.write(duplicates); // = 1,3 (actual array == [1, 3])[1, 2, 2, 4, 3, 4].filter((e, i, a) => a.indexOf(e) !== i) // [2, 4]
Also in JavaScript:
- angular new service
- rawer icon dont opne
- how to populate a list in html with javascript
- angular convert boolean to yes no
- get radio button value javascript
- angular 7 folder structure best practices
- how to revert angular cli version
- express bodyparser
- how create array with names of files in folder nodejs
- destructure array javascript
- go to another page javascript
- create responsive navbar without javascript
- reactjs fix ios apostrophe encoding
- slick js
- jquery attr
- jquery remove all options but first
- hot to start cypress
- jquery number format comma
- decimal to base 32 javascript
- kotlin repeat n times
- javascript send post data with ajax
- js onscroll event
- get youtube embed code from url
- javascript regex Zero or one occurrence