JavaScript toString()Method
Examples
Convert a Boolean value to a string:
var bool = new Boolean(1);
var myvar = bool.toString();
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
![]()
![]()
![]()
![]()
![]()
All major browsers support the toString() method
Syntax
boolean.toString()
Return Value
| Type | Description |
|---|---|
| String | "true" or "false" |
Technical Details
| JavaScript Version: | 1.1 |
|---|
Other Extensions
JavaScript Boolean Object