javascript find unique values in array

44

javascript find unique values in array -

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

// unique is ['a', 1, 2, '1']

unique values in array javascript -

let uniqueItems = [...new Set(items)]

Comments

Submit
0 Comments