Convert boolean to string by calling its toString method in JavaScript

Description

The following code shows how to convert boolean to string by calling its toString method.

Example


<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
boolObj = new Boolean(false);<!--from   w w  w  .  j  ava2  s .co m-->
if(boolObj.toString() == "false")
document.writeln("EQUAL");
else
document.writeln("NOT Equal");
</script>
</body>
</html>

Click to view the demo

The code above generates the following result.

Convert boolean to string by calling its toString method in JavaScript