Reputation: 1032
Helo guys, could you help with:
I need a method to lodash which return:
_.method( [1,2,3,4,5,6,7], [1,2,3] ) => [4,5,6,7]
In other words method which return non-share elements.
Best regards Greg.
Upvotes: 2
Views: 41
Reputation: 1032
I found:
For Objects it should be:
albumNotPhotos = _.differenceWith(this.albumNotPhotos, this.albumPhotos, _.isEqual);
Thanks and regards!@
Upvotes: 0
Reputation: 386634
You could use _.difference
.
Creates an array of
array
values not included in the other given arrays usingSameValueZero
for equality comparisons. The order and references of result values are determined by the first array.
var result = _.difference([1, 2, 3, 4, 5, 6, 7], [1, 2, 3]);
console.log(result);
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.min.js"></script>
Upvotes: 3