Andrea Giammarchi andrea.giammarchi at
Mon Jun 15 11:36:47 UTC 2015

that's no how usually you create RegExp

RegExp('yep', 'g');
new RegExp('yep', 'g');
both will produce similar RegExp instances (every time a new one).

Using the RegExp constructor as RegExp wrapper is a very unusual pattern I
haven't seen before. So yes, in that case we have some sort of unusual
behavior that yet makes little sense to me because `RegExp.length` is 2 and
you are potentially ignoring the second argument

TypeError: Cannot supply flags when constructing one RegExp from another at
new RegExp

So beside creating a `new RegExp` from another `RegExp` knowing what you
are doing is the only pattern I can think of that might make sense (in
terms of having index and stuff reset ... if that's even the case)

Good spot though.


On Mon, Jun 15, 2015 at 8:37 AM, Rock <zloirock at> wrote:

> Benjamin Gruenaum, Andrea Giammarchi, you are wrong about RegExp:
> ```js
> var re = /./;
> new RegExp(re) === re; // false
> RegExp(re) === re; // true
> ```
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list