Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript constructor Property

JavaScript constructor Property

String Object Reference JavaScript String object


Definition and Usage

The constructor property returns the function that created the String object.

Syntax

string

.constructor


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the constructor property


Example

Example

Return the function that created the String object:

var

txt

=

"

Hello World!

"

;

document

.

write

(

txt

.

constructor

)

;

Output of the above example:

function String() { [native code] }

Try it »


String Object Reference JavaScript String object