The lodash _.untion method and Sets
1 - basic lodash union example with arrays
So a basic example of the lodash union method would be to just call the method and pass one or more arrays as arguments. The result that is returned is an array of values where only unique values are in the resulting array. In other words it is a way to omit values that repeat.
2 - Nested Objects with the lodash union, and lodash flatten methods
If I use a method like lodash union in a project I might run into problems with nested objects. When giving arrays of primitives the numbers are the values that are going to be tested as to the fact that they are unique or not. However when having arrays of objects that are also arrays, it is the arrays themselves that are tested, not the nested elements or object key values. If this is a problem then the nested objects will need to be flattened first. So it might be worth pointing out that in lodash there are the flatten, flattenDeep, and flattenDepth methods that can sometimes help in these cases.
4 - Conclusion