Skip to content

Commit

Permalink
Merge pull request getify#694 from magul/findIndex-instead-of-find
Browse files Browse the repository at this point in the history
Fixing note about passing this to findIndex().
  • Loading branch information
getify committed Mar 20, 2016
2 parents 66143a1 + d3f544b commit 704f828
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion es6 & beyond/ch6.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ points.findIndex( function matcher(point) {

Don't use `findIndex(..) != -1` (the way it's always been done with `indexOf(..)`) to get a boolean from the search, because `some(..)` already yields the `true`/`false` you want. And don't do `a[ a.findIndex(..) ]` to get the matched value, because that's what `find(..)` accomplishes. And finally, use `indexOf(..)` if you need the index of a strict match, or `findIndex(..)` if you need the index of a more customized match.

**Note:** As with other array methods that take callbacks, `find(..)` takes an optional second argument that if set will specify the `this` binding for the callback passed as the first argument. Otherwise, `this` will be `undefined`.
**Note:** As with other array methods that take callbacks, `findIndex(..)` takes an optional second argument that if set will specify the `this` binding for the callback passed as the first argument. Otherwise, `this` will be `undefined`.

### `entries()`, `values()`, `keys()` Prototype Methods

Expand Down

0 comments on commit 704f828

Please sign in to comment.