To use the union
function from the Underscore library in Typescript, you will first need to install Underscore through npm:
index.ts23 chars2 lines
Next, you can import the union
function from the Underscore module in your Typescript file:
index.ts36 chars2 lines
Now you can use the union
function to create a union array of two or more arrays, like this:
index.ts208 chars7 lines
The union
function takes two or more arrays as arguments and returns a new array with unique values from all the arrays. The returned array will contain only one occurrence of each value, even if that value is present in multiple input arrays.
gistlibby LogSnag