JavaScript RegExp constructor property
Example
Returns the function of the regular expression prototype:
var
patt
=
new
RegExp
(
"
RUNOOB
"
,
"
g
"
)
;
var
res
=
patt
.
constructor
;
Try it »
Definition and Usage
In JavaScript, the constructor property returns the constructor function of an object.
The return value is a reference to the function, not the function name:
JavaScript Regular expressions The 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 ** function String() { [native code] }**
If a variable is an array you can use the constructor property to identify 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 |
JavaScript RegExp Object