Boolean toString() Method - Javascript Boolean

Javascript examples for Boolean:toString


The toString() method returns a boolean value as a string.

This method is called whenever a boolean is used in a string operation.



Return Value:

A String, either "true" or "false"

The following code shows how to Convert a Boolean value to a string:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/*from  ww w  .j av a  2  s . c  om*/
    var bool = true;
    var x = bool.toString()
    document.getElementById("demo").innerHTML = x;


Related Tutorials