JavaScript Global method: String()
[this page | pdf | back links]
The JavaScript
Global
String() method converts an
object to a string. It returns the same as the toString()
method of the object.
It
has the following syntax with the following parameters:
String(x)
Parameter
|
Required / Optional
|
Description
|
x
|
Required
|
Input parameter.
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,th,tr,td {border: 1px solid black; border-collapse :collapse;}
</style>
</head>
<body>
<table>
<tr>
<th>Example</th>
<th>Resulting value of <code>x</code></th>
</tr>
<tr>
<td><code id="Example"></code></td>
<td><code id="Result"></code></td>
</tr>
</table>
<script>
document.getElementById("Example").innerHTML =
'var y = (3 == 4); // so y is false<br>var x = String(y).toUpperCase();';
var y = (3 == 4);
document.getElementById("Result").innerHTML =
String(y).toUpperCase();
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedJavaScriptMethodGlobalString() {
return (String((3 == 4)).toUpperCase()) == "FALSE");
} |
NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)