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


that's no how usually you create RegExp

```js
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.

Regards







On Mon, Jun 15, 2015 at 8:37 AM, Rock <zloirock at zloirock.ru> 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 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/20150615/d23a28d4/attachment.html>


More information about the es-discuss mailing list