WHAT'S NEW?
Loading...

Using string - toLowerCase (), toString (), toUpperCase (), valueOf () in javascript with example - Tech-n-Savvy Blogger


toLowerCase ()

This method returns the calling string value converted to lowercase.

Syntax

Its syntax is as follows:

string.toLowerCase( )

Return Value

Returns the calling string value converted to lowercase.


Example

Try the following example.

<html>
<head>

<title>JavaScript String toLowerCase() Method</title>

</head>

<body>

<script type="text/javascript">

var str = "Apples are round, and Apples are Juicy."; document.write(str.toLowerCase( ));

</script>

</body>

</html>

Output

apples are round, and apples are juicy.


toString ()

This method returns a string representing the specified object.

Syntax

Its syntax is as follows:

string.toString( )

Return Value

Returns a string representing the specified object.

Example

Try the following example.

<html>

<head>

<title>JavaScript String toString() Method</title>

</head>

<body>

<script type="text/javascript">

var str = "Apples are round, and Apples are Juicy.";

document.write(str.toString( ));

</script>

</body>

</html>

Output

Apples are round, and Apples are Juicy.


toUpperCase ()

This method returns the calling string value converted to uppercase.

Syntax

Its syntax is as follows:

string.toUpperCase( )

Return Value

Returns a string representing the specified object.


Example

Try the following example.


<html>

<head>

<title>JavaScript String toUpperCase() Method</title>

</head>

<body>
<script type="text/javascript">

var str = "Apples are round, and Apples are Juicy.";

document.write(str.toUpperCase( ));

</script>

</body>

</html>

Output

APPLES ARE ROUND, AND APPLES ARE JUICY.


valueOf ()

This method returns the primitive value of a String object.

Syntax

Its syntax is as follows:

string.valueOf( )

Return Value

Returns the primitive value of a String object.

Example

Try the following example.


<html>

<head>

<title>JavaScript String valueOf() Method</title>

</head>

<body>

<script type="text/javascript">

var str = new String("Hello world");

document.write(str.valueOf( ));

</script>

</body>

</html>

Output

Hello world


0 comments:

Post a Comment