According to this MDN link, the find() method takes a callback function that can take three arguments: the current array element, the index of the current array element, and the array that the method is being called upon.
So:
var r = [2, 9, 11]; console.log(r.find(function(e, i, r) {
if (e % 2 === 0)
return e; }))
returns 2, as I would expect.
However:
var r = [2, 9, 11];
console.log(r.find(function(e, i, r) {
if (e % 2 === 0)
return i;
}))
return undefined (when I expect 0),
and
var r = [2, 9, 11];
console.log(r.find(function(e, i, r) {
if (e % 2 === 0)
return r;
}))
returns 2 (when I expect [2, 9, 11]).
Can someone please explain what I am not properly understanding?