How to get unique values from an Array

let testArray = [1,2,3,1,3,4,1,1,2]

let uniqueValues = [...new Set(testArray )];
The restult uniqueValues array will be [1,2,3,4]

We can use Set function for get the unique values from the array

Leave a comment

Your email address will not be published. Required fields are marked *