Jussi Kalliokoski (2013-12-18T15:22:51.000Z)
On Dec 18, 2013 3:31 PM, "Mathias Bynens" <mathias at qiwi.be> wrote:
>
> Both `String.prototype.startsWith` and `String.prototype.endsWith` throw
a `TypeError` if the first argument is a RegExp:
>
> > Throwing an exception if the first argument is a RegExp is specified in
order to allow future editions to define extends that allow such argument
values.
>
> However, this is not the case for `String.prototype.contains`, even
though it’s a very similar method. As per the latest ES6 draft,
`String.prototype.contains(regex)` behaves like
`String.prototype.contains(String(regex))`. This seems inconsistent. What’s
the reason for this inconsistency?

Not sure why the inconsistency,  but afaik with for example WebIDL if you
say something accepts a string, it accepts pretty much anything that can be
coerced to a string, so the case of `contains` may come from there.

> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131218/43f52849/attachment.html>
domenic at domenicdenicola.com (2014-01-06T14:02:23.728Z)
Not sure why the inconsistency,  but afaik with for example WebIDL if you
say something accepts a string, it accepts pretty much anything that can be
coerced to a string, so the case of `contains` may come from there.