Convert Boolean Value to String in JavaScript



To convert a Boolean value to string value in JavaScript, use the toString() method. This method returns a string of either "true" or "false" depending upon the value of the object.

Example

You can try to run the following code to convert a boolean value to string value −

Live Demo

<html>
   <head>
      <title>JavaScript toString() Method</title>
   </head>

   <body>
      <script>
         var flag = new Boolean(true);
         document.write( "flag.toString is : " + flag.toString() );
      </script>
   </body>
</html>
Updated on: 2020-06-15T06:58:38+05:30

16K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements