R
R
Rag'n' Code Man2021-06-06 05:08:42
JavaScript
Rag'n' Code Man, 2021-06-06 05:08:42

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


- It was necessary to write such functions, but somehow I can’t figure out how to call them .

The first one I called arraysIntersection(), which does not particularly reflect how they

intersect excludingIntersection().

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-06-06
@iDmitriyWinX

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 question

Ask a Question

731 491 924 answers to any question