ES6 - toString ()


Advertisements

This method returns a string of either "true" or "false" depending upon the value of the object.

Following is the syntax for the same.

boolean.toString()

Example

<html>
   <head>
      <title>JavaScript toString() Method</title>
   </head>
   <body>
      <script type="text/javascript">
         var flag = new Boolean(false);
         document.write( "flag.toString is : " + flag.toString());
      </script>
   </body>
</html>

The following output is displayed on successful execution of the above code.

flag.toString is : false
Advertisements