Start of main content
# Array similarity

JavaScript, Array, Math · Oct 22, 2020

Returns an array of elements that appear in both arrays.

const similarity = (arr, values) => arr.filter(v => values.includes(v));
similarity([1, 2, 3], [1, 2, 4]);

## More like this

A snippet collection of math helpers and algorithms implemented in JavaScript.

Collection · 93 snippets

Returns the elements that exist in both arrays, after applying the provided function to each array element of both.

JavaScript, Array · Oct 20, 2020

Returns the symmetric difference between two arrays, after applying the provided function to each array element of both.

JavaScript, Array · Oct 22, 2020

Returns the difference between two arrays, after applying the provided function to each array element of both.

JavaScript, Array · Oct 19, 2020