This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

toString

Summary

Returns a string representation of a Boolean object.

Syntax

boolean.toString()
boolean
Required. An object for which to get a string representation.

Return Value

If the Boolean value is true , returns "true". Otherwise, returns "false".

Examples

The following example illustrates the use of the toString method.

var s = new Boolean(0);
 document.write(s.toString());

 // Output: false;

Create a Boolean variable and convert it to a string

// Create a Boolean Variable
var flag = new Boolean(true);
// Convert the variable to a string
var myVar = flag.toString();
// myVar returns the string "true"

See also

Specification

Boolean Objects ECMAScript® Language Specification Standard ECMA-262 5.1 Edition / June 2011

Attributions

  • Microsoft Developer Network: Article