Accepting an array as the first parameter to String.prototype.includes

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Mar 10 23:48:58 UTC 2015


not sure I understand what you say but `["maria",
"marianne"].some(str.contains,
str)` means `["maria", "marianne"].some(function (value) {return
this.contains(value)}, str)` ... no bind nor arrow function needed, the
function `str.contains` is executed with `str` as context per each
iteration. Is that confusing? 'cause that's how
some/every/forEach/map/filter work

On Tue, Mar 10, 2015 at 10:18 PM, Garrett Smith <dhtmlkitchen at gmail.com>
wrote:

> On 3/10/15, Andrea Giammarchi <andrea.giammarchi at gmail.com> wrote:
> > contains better than indexOf ? I'd agree only if contains wasn't
> accepting
> > any extra argument, which makes it even more (pointless?) similar to
> > indexOf.
> >
> > If it had only one incoming parameter, you could have `["maria",
> > "marianne"].some(str.contains, str)` and win over all other examples. but
> > just the `!=-1` or `>-1` as reason to prefer contains? ... dunno, I
> think I
> > have 99 problems in JS related development, `>-1` ain't one :-/
> >
>
> Evidently.
>
> I can only guess that str is a string. Strings don't have a contains
> method, nor was one proposed the call str.contains(str) inside of a
> call to some looks like a confused mistake.
> --
> Garrett
> @xkit
> ChordCycles.com
> garretts.github.io
> personx.tumblr.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150310/bd5f0ad1/attachment.html>


More information about the es-discuss mailing list