This logic is convenient if function accept string or regexp, like `String#split`, for convert it to regexp. Behavior with second argument is changed in ES6 and fixed in latest FF, `core-js` and `es6-shim`. Sorry for reply w/o subject - problem with mail client :)
15.06.2015, 17:36, "Andrea Giammarchi" <[email protected]>:
that's no how usually you create RegExp```jsRegExp('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.RegardsOn Mon, Jun 15, 2015 at 8:37 AM, Rock <[email protected]> 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
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
--
С уважением,
Denis Pushkarev
Denis Pushkarev
79619864927
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

