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

JavaScript valueOf() Method

JavaScript valueOf() Method

String Object Reference JavaScript String object


Definition and Usage

The valueOf() method can return the primitive value of a String object.

Note: The valueOf() method is usually called automatically by JavaScript in the background, rather than being explicitly written in the code.

Syntax

string

.valueOf()


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the valueOf() method


Example

Example

Returns the primitive value of a String object:

The output of the above example is:

Hello world!

Try it »


String Object Reference JavaScript String object