To use the uniq
function from the Underscore library in JavaScript, first you need to include the Underscore library in your project:
67 chars2 lines
Then you can call the uniq
function passing an array as an argument and it will return a copy of the array with duplicates removed:
index.tsx117 chars4 lines
Alternatively, you can use the chain syntax provided by Underscore:
index.tsx127 chars4 lines
In both cases, the output will be an array with unique values only.
gistlibby LogSnag