JavaScript RegExp Constructor
Property
Example
Returns the function that created the regular expression prototype:
var patt = new RegExp("tutorialpro", "g");
var res = patt.constructor;
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:
JavaScript RegExp constructor property returns function RegExp() { [native code] }
JavaScript array constructor property returns function Array() { [native code] }
JavaScript number constructor property returns function Number() { [native code] }
JavaScript string constructor property returns function String() { [native code] }
If a variable is an array, you can use the constructor property to check.
Browser Support
The numbers in the table specify the first browser version that fully supports the 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 |