Latest web development tutorials

JavaScript valueOf () method

String Object Reference JavaScript String Object

Definition and Usage

valueOf () method returns the original value of the String object.

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

grammar

string.valueOf()


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support valueOf () method


Examples

Examples

Returns a String object's original value:

<script>

var str="Hello world!";
document.write(str.valueOf());

</script>

Examples of the above output:

Hello world!

try it"


String Object Reference JavaScript String Object