how to find unique elements in array in javascript
const myArray = [1,2,3,1,5,8,1,2,9,4];
const unique = [...new Set(myArray)]; // [1, 2, 3, 5, 8, 9, 4]
const myString = ["a","b","c","a","d","b"];
const uniqueString = [...new Set(myString)]; //["a", "b", "c", "d"]let a = ["1", "1", "2", "3", "3", "1"];
let unique = a.filter((item, i, ar) => ar.indexOf(item) === i);
console.log(unique);
Also in JavaScript:
- javascript biggest number
- ejs
- remove duplicates from array of objects javascript
- javascript sort map by value
- how to remove the last character from a string in javascript
- math random equitative js
- new map js
- javascript string to integer
- get value in maps loop using enzym
- sinon expect to match object
- combine p5 with react
- import javascript
- Flip a coin
- openssl error Subject does not start with '/'
- jquery get value by name
- regular expression match interviewbit solution
- js variable
- javascript cut string if too long
- how to make an object stop at the end of your canvas p5js
- javascript redirect new window
- javascript find a prime number
- javascript object string property
- comment out in javascript
- iterate over node object children