array to set javascript code example
Example 1: array to set javascript
const myArray = [1,2,3,1,5,8,1,2,9,4];
const unique = [...new Set(myArray)];
const myString = ["a","b","c","a","d","b"];
const uniqueString = [...new Set(myString)];
Example 2: set js
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)])
Example 3: create set from list javascript
var arr = [55, 44, 65];
var set = new Set(arr);
Example 4: js new array from new set
return Array.from(new Set(this.posts.map(e => e.category)))