koala-moon

Javascript – distinct values from an array

The problem: How to get the unique values from this array?

const userIds = [12, 14, 44, 12, 56, 30, 12, 14]

ES6 solution

const unique = [...new Set(usersIds)]; 

Returns

[12, 14, 44, 56, 30]

Comments

64 responses to “Javascript – distinct values from an array”