JavaScript RegExp constructorProperty

RegExp 对象参考手册JavaScript RegExp Object

Examples

Returns the constructor function of the regular expression prototype:

var patt = new RegExp("EXAMPLE", "g"); var res = patt.constructor;

Try it Yourself »

Definition and Usage

In JavaScript, the constructor property returns the object's constructor function.

The return value is a reference to the function, not the function name:

JavaScript Regular expressionThe constructor property returns function RegExp() { [native code] }

The JavaScript Array constructor property returns function Array() { [native code] }

The JavaScript Number constructor property returns function Number() { [native code] }

The JavaScript String constructor property returns returns function String() { [native code] }

If a variable is an array, you can use the constructor property to determine it.


Browser Support

The numbers in the table indicate the first browser version that supports this property.

Property
constructor Yes Yes Yes Yes Yes

Syntax

RegExpObject.constructor

Parameters

No parameters.

Technical Details

Return value: function RegExp() { [native code] }
JavaScript version: ECMAScript 1


RegExp 对象参考手册JavaScript RegExp Object

Other Extensions