THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JavaScript RegExp constructor Property

RegExp Object Reference 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

Internet Explorer Firefox Opera Google Chrome Safari

The constructor property is supported in all major browsers.


Syntax

RegExpObject.constructor

Technical Details

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

RegExp Object Reference JavaScript RegExp Object