Home » JavaScript Tutorial

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();

Parameter(s):

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 = "[email protected]";
	document.write(str.valueOf() + "<br/>");
</script>

Output

Hello
IncludeHelp
[email protected]





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.