Skip to content

Issue with "RegExp": lastIndex is not a static property of RegExp #2708

@cpcallen

Description

@cpcallen

MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp

What information was incorrect, unhelpful, or incomplete?

The Static Properties section suggests the existence of a property, RegExp.lastIndex, that does not exist.

Specific section or headline?

Static Properties

What did you expect to see?

I expected to see .lastIndex listed in the Instance Properties section.

I'm not sure what the best notation would be. RegExp.lastIndex is clearly wrong because no such property exists. RegExp.prototype.lastIndex is also misleading, because that property does not exist either. Maybe it should just be listed as .lastIndex. In any case, however, clearly .lastIndex belongs in Instance Properties rather than Static Properties.

Did you test this? If so, how?

$ node
Welcome to Node.js v12.20.1.
Type ".help" for more information.
> Object.getOwnPropertyDescriptor(RegExp, 'lastIndex');
undefined
> Object.getOwnPropertyDescriptor(/foo/, 'lastIndex');
{ value: 0, writable: true, enumerable: false, configurable: false }

See also ECMA 262, §22.2.3.2.1:

  1. Perform ! DefinePropertyOrThrow(obj, "lastIndex", PropertyDescriptor { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: false }).
MDN Content page report details

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions