A non pure lodash way to do this but using the array.concat function you are able to do this pretty simply along uniq()
:
(一种非纯lodash的方法,但是使用array.concat函数,您可以非常简单地沿uniq()
:)
var objUnion = function(array1, array2, matcher) {
var concated = array1.concat(array2)
return _.uniq(concated, false, matcher);
}
An alternative approach would be to use flatten() and uniq() :
(另一种方法是使用flatten()和uniq() :)
var union = _.uniq(_.flatten([array1, array2]), matcherFn);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…