RegExps that don't modify global state?

Brendan Eich brendan at
Wed Sep 24 14:21:30 PDT 2014

C. Scott Ananian wrote:
> On Wed, Sep 24, 2014 at 2:36 AM, Viktor Mukhachev<esdiscusser at>  wrote:
>> >  RegExp.prototype.exec returns array with extra properties (input, index), may be it is better to return something other for `run`, frozen value object with `0`, `1`, ...  keys for example. What do you think?
> For ES6 this can return a proper subclass of Array.

Adding a new method still leaves the old ones around and developers will 
have problems until some later date. Doesn't mean we shouldn't, but in 
the mean time the API surface grows. Is it worth it compared to the 

1. Support configurable as an attribute on the magic, not-yet-specified 
RegExp statics, so they can be deleted. SES (Caja) wants this, others 
could use it, libraries could do it at startup.

2. Add a RegExp instance flag (don't overload u) that disables updating 
the RegExp statics.

TC39 wants both of these, per today's meeting.

>> >  Actually, `index` and "input" are not very interesting, as input is a string passed to `exec` and index = string.indexOf(match[0], lastIndex), right?
> Not in the presence of lookahead assertions.

Good point!


More information about the es-discuss mailing list