- The compressed version is only 345 caracters long.
- Faster than common libraries, even a large number of arrays, or on very big arrays. (See benchmarks)
array_intersect(array1, array2, ..., arrayN)
[ Credits to https://gist.github.com/lovasoa/3361645 ]
The idea is simple and comes from here: http://pioupioum.fr/developpement/javascript-array-intersection.html.
To make short story even shorter: It creates a javascript object, the keys of which are the elements of the smallest of the arrays we want to intersect.
A comparision for all array intersections - https://codeburst.io/optimizing-array-analytics-in-javascript-part-two-search-intersection-and-cross-products-79b4a6d68da0