Latest web development tutorials
 

JavaScript RegExp constructor Property

< JavaScript RegExp Object

Example

The constructor property returns a regular expression's constructor function:

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

The result of res will be:

function RegExp() { [native code] }
Try it Yourself »

Definition and Usage

In JavaScript, the constructor property returns the constructor function for an object.

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

For JavaScript regular expressions the constructor property returns function RegExp() { [native code] }

For JavaScript numbers the constructor property returns function Number() { [native code] }

For JavaScript strings the constructor property returns function String() { [native code] }


Browser Support

Property
constructor Yes Yes Yes Yes Yes

Syntax

RegExpObject.constructor

Technical Details

Return Value: function RegExp() { [native code] }
JavaScript Version: 1.1

< JavaScript RegExp Object