Answer the question
In order to leave comments, you need to log in
How can these types of intersection of arrays be called?
How would you call such array intersection functions?
[1, 2, 3] + [1, 2, 3, 4, 5] = [1, 2, 3, 4, 5] // 1, 2, 3 наложились друг на друга, а 4, 5 — добавились
[1, 2, 3, 4, 5] + [2, 4, 5] = [1, 3] // из массива 1 удаляются элементы, указанные в массиве 2
arraysIntersection()
, which does not particularly reflect how they excludingIntersection()
.
Answer the question
In order to leave comments, you need to log in
Lodash already has such methods, use them (or their name, so as not to confuse anyone):
1. https://lodash.com/docs/4.17.15#union
2. https://lodash.com/docs/ 4.17.15#difference
Unless of course the behavior is fully consistent, otherwise it can be even more confusing, in which case it is better to use a derived name.)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question