JavaScript toString()Method

Boolean 对象参考手册JavaScript Boolean Object

Examples

Convert a Boolean value to a string:

var bool = new Boolean(1);
var myvar = bool.toString();

myvarOutput:

true

Try it Yourself »

Definition and Usage

The toString() method converts a logical value to a string and returns the result.

Note:JavaScript automatically calls this method when a Boolean object needs to be converted to a string.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the toString() method


Syntax

boolean.toString()

Return Value

Type Description
String "true" or "false"

Technical Details

JavaScript Version: 1.1


Boolean 对象参考手册JavaScript Boolean Object

Other Extensions