Array confusion with find and includes

Viewed 89

Given the following arrays:

const x = [2, 14, 54, 109, 129, 136, 165, 312, 320, 330, 335, 348, 399, 440, 450, 461, 482, 501, 546, 547, 549, 559, 582, 584, 615, 620, 647, 682];
const y = [539, 681, 682, 683];

Using node v 7.3.0 I observe the following unexpected behavior:

[> x.find(y.includes, y);
undefined
[> y.find(x.includes, x);
682

Sample Snippet:

const x = [2, 14, 54, 109, 129, 136, 165, 312, 320, 330, 335, 348, 399, 440, 450, 461, 482, 501, 546, 547, 549, 559, 582, 584, 615, 620, 647, 682];
const y = [539, 681, 682, 683];

console.log(x.find(y.includes, y))
console.log(y.find(x.includes, x))

However code like x.find(element => y.includes(element)); always finds the element as expected.

I don't get why the two calls that just use find and includes would ever yield different results and would be delighted if someone knows an explanation.

1 Answers
Related