String toLowerCase() Method with Example in JavaScript

JavaScript String toLowerCase() Method: Here, we are going to learn about the toLowerCase() method of the string in JavaScript with Example.
Submitted by IncludeHelp, on February 05, 2019

String toLowerCase() Method

toLowerCase() Method is a string method in JavaScript, it is used to converts all alphabets in lowercase and returns the new string with lowercase alphabets.

Syntax:

    new_string = str.toLowerCase();

Here,

  • str is the main string to be converted.
  • new_string is the returned new string with all alphabets in lowercase.

Examples:

    Input: "Hello World!"
    Output: "hello world!"
    Input: "Hello123@"
    Output: "hello123@"

Code:

<html>
<head>
<title>JavaScipt Example</title>
</head>

<body>
<script>		
	var main_str = "Hello World!";
	var new_str = main_str.toLowerCase();
	document.write("main_str =  " + main_str + "<br>");
	document.write("new_str =  " + new_str + "<br>");

	main_str = "Hello123@";
	new_str = main_str.toLowerCase();
	document.write("main_str =  " + main_str + "<br>");
	document.write("new_str =  " + new_str + "<br>");	
</script>
</body>
</html>

Output

main_str = Hello World!
new_str = hello world!
main_str = Hello123@
new_str = hello123@

JavaScript String Object Methods »




Comments and Discussions!

Load comments ↻





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