To use the union
function from lodash in javascript, we first need to install it with npm
:
19 chars2 lines
Then, we can include it in our javascript code with require
:
index.tsx29 chars2 lines
Now, we can use the union
function to combine arrays and remove duplicates:
index.tsx159 chars7 lines
The union
function takes multiple arrays as arguments and returns a new array with all unique values from each array, in the order that they appear.
gistlibby LogSnag