How to use String in JavaScript

This article describe about String() Function in JavaScript.
  • 1224

String() Function in JavaScript

It is used to convert object to string value.

Syntax

String(object)

 

Parameter Description
object Required. JavaScript object.

Example

<!DOCTYPE html>

<html>

<body>

<script type="text/javascript">

    var t1 = new Boolean(1);

    var t2 = new Boolean(0);

    var t3 = new Boolean(true);

    var t4 = new Boolean(false);

    var t5 = new Date();

    var t6 = new String("777 888");

    var t7 = 54321;

    document.write(String(t1) + "<br />");

    document.write(String(t2) + "<br />");

    document.write(String(t3) + "<br />");

    document.write(String(t4) + "<br />");

    document.write(String(t5) + "<br />");

    document.write(String(t6) + "<br />");

    document.write(String(t7) + "<br />");

</script>

</body>

</html>

 

Output


pic10.jpg 

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.