ES6 - Boolean Method toString()


Advertisements


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

Syntax

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 

es6_boolean.htm

Advertisements