Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript toString() Method

JavaScript toString() Method

Boolean Object Reference JavaScript Boolean object

Example

Converts a boolean value to a string:

var bool = new Boolean(1);

var myvar = bool.toString();

myvar Output result:

true

Try it »


Definition and Usage

The toString() method converts a boolean 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 Object Reference JavaScript Boolean object