then none of them should throw, imho startsWith is like dropping the `/^` form a `RegExp`, endsWith like dropping the `$/` part .. that's it
The problem with RegExp is usually the safe escaping, having 1 char less to type for a `.test()` - so actually counting chars in the method name is even more - is not a win In `/^th(is|at)$/.test(str)` the useful `RegExp` part is in the middle so what was the reason to not coerce to string as basically every other `String.prototype` method does already if consistency was actually the reason ? Is it because split accepts `RegExp` too ? 'cause that's completely different scenario. On Wed, Dec 18, 2013 at 1:01 PM, Jason Orendorff <jason.orendo...@gmail.com>wrote: > On Wed, Dec 18, 2013 at 11:16 AM, Benjamin (Inglor) Gruenbaum > <ing...@gmail.com> wrote: > > May I ask what String.prototype.contains accomplish with a regular > > expression (that we don't already have with `RegExp.test`)? > > Consistency with the other methods, maybe? It would be bad API design > to insist on "there's only one way to do it" at the expense of > consistency and the principle of least astonishment. > > -j > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss