Description
The String() function is used to convert the value of an object to a string.
This function has the form:
String(object)
Parameter | Description |
---|---|
object | (required) A JavaScript object |
Examples
The following example shows the basic use of this method.
<script>
var n1 = new Date();
var n2 = new String("123.45");
var n3 = new Boolean(true);
document.write(String(n1));
document.write("<br />");
document.write(String(n2));
document.write("<br />");
document.write(String(n3));
</script>
This produces the following result:
Browser Support
Firefox | IE | Chrome | Opera | Safari |
---|---|---|---|---|