Monday, 27 November 2023

js get unique value

 https://stackoverflow.com/questions/1960473/get-all-unique-values-in-a-javascript-array-remove-duplicates


// usage example:
var myArray = ['a', 1, 'a', 2, '1'];
var unique = myArray.filter((value, index, array) => array.indexOf(value) === index);

console.log(unique); // unique is ['a', 1, 2, '1']

No comments:

Post a Comment