RegExps that don't modify global state?

C. Scott Ananian ecmascript at cscott.net
Wed Sep 24 07:18:37 PDT 2014


On Wed, Sep 24, 2014 at 2:36 AM, Viktor Mukhachev <esdiscusser at yandex.ru> 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.

> 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.
  --scott


More information about the es-discuss mailing list