Array.prototype.findIndex(fn, startIndex = 0)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Array.prototype.findIndex(fn, startIndex = 0)

Cyril Auburtin
It should be possible to add a second optional argument to the `find` and `findIndex` array methods, similarly to `indexOf`

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Array.prototype.findIndex(fn, startIndex = 0)

Andrea Giammarchi-2
isn't the second argument already reserved for the context?

```js
[1, 2, 3].findIndex(function (i) { return i == this; }, 2);
// 1
```

On Thu, Aug 15, 2019 at 11:51 PM Cyril Auburtin <[hidden email]> wrote:
It should be possible to add a second optional argument to the `find` and `findIndex` array methods, similarly to `indexOf`
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Array.prototype.findIndex(fn, startIndex = 0)

Jordan Harband
I believe every array iteration method that takes a callback, except for reduce and reduceRight, take an optional receiver as the last argument (the `this` value), so they can't be meaningfully/ergonomically extended.

On Thu, Aug 15, 2019 at 3:00 PM Andrea Giammarchi <[hidden email]> wrote:
isn't the second argument already reserved for the context?

```js
[1, 2, 3].findIndex(function (i) { return i == this; }, 2);
// 1
```

On Thu, Aug 15, 2019 at 11:51 PM Cyril Auburtin <[hidden email]> wrote:
It should be possible to add a second optional argument to the `find` and `findIndex` array methods, similarly to `indexOf`
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss