×

Index

JavaScript Tutorial

JavaScript Examples

CSS Tutorial

CSS Examples

String valueOf() Method with Example in JavaScript

JavaScript String valueOf() Method: Here, we are going to learn about the valueOf() method of the string in JavaScript with Example.
Submitted by Shivang Yadav, on February 23, 2020

JavaScript | String valueOf() Method

The String.valueOf() method in JavaScript is used to return the value of the given string.

Syntax

    str.valueOf();

Parameters

The method accepts no parameter.

Return Value

The return type of this method is string which is the string of the given object.

Browser support:

Chrome, Internet explorer, Mozilla, Safari, Opera mini.

Example 1

<script>
	document.write("hello".valueOf() + "<br/>");
	document.write("Hello".valueOf() + "<br/>");
	document.write("123456".valueOf() + "<br/>");
	document.write("IncludeHelp".valueOf() + "<br/>");
	document.write("www.includehelp.com".valueOf() + "<br/>");
</script>

Output

hello
Hello
123456
IncludeHelp
www.includehelp.com

Example 2

<script>
	str = "Hello";
	document.write(str.valueOf() + "<br/>");

	str = "IncludeHelp";
	document.write(str.valueOf() + "<br/>");

	str = "IncludeHelp01234@2901";
	document.write(str.valueOf() + "<br/>");
</script>

Output

Hello
IncludeHelp
IncludeHelp01234@2901

JavaScript String Object Methods »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.