Revision 88457 of Boolean.prototype.toString()

  • Revision slug: JavaScript/Reference/Global_Objects/Boolean/toString
  • Revision title: toString
  • Revision id: 88457
  • Created:
  • Creator: evilpie
  • Is current revision? No
  • Comment Reverted to earlier version; 7 words added, 3 words removed

Revision Content

 

Summary

Returns a string representing the specified Boolean object.

Method of Boolean
Implemented in: JavaScript 1.1
ECMAScript Edition: ECMA-262

Syntax

bool.toString()

Parameters

None.

Description

The Boolean object overrides the toString method of the Object object; it does not inherit Object.toString. For Boolean objects, the toString method returns a string representation of the object.

JavaScript calls the toString method automatically when a Boolean is to be represented as a text value or when a Boolean is referred to in a string concatenation.

For Boolean objects and values, the built-in toString method returns the string "true" or "false" depending on the value of the boolean object. In the following code, flag.toString returns "true".

var flag = new Boolean(true)
var myVar = flag.toString()

See Also

Object.toString

{{ languages( { "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/Boolean/toString", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/Boolean/toString" } ) }}

Revision Source

<p>
 </p>
<h3 name="Summary">Summary</h3>
<p>Returns a string representing the specified Boolean object.</p>
<table class="fullwidth-table"> <tbody> <tr> <td class="header" colspan="2">Method of <a href="/en/JavaScript/Reference/Global_Objects/Boolean" title="en/JavaScript/Reference/Global_Objects/Boolean">Boolean</a></td> </tr> <tr> <td>Implemented in:</td> <td>JavaScript 1.1</td> </tr> <tr> <td>ECMAScript Edition:</td> <td>ECMA-262</td> </tr> </tbody>
</table>
<h3 name="Syntax">Syntax</h3>
<p><code><em>bool</em>.toString()</code></p><h3 name="Parameters"> Parameters </h3>
<p>None.
</p>
<h3 name="Description">Description</h3>
<p>The <a href="/en/JavaScript/Reference/Global_Objects/Boolean" title="en/JavaScript/Reference/Global_Objects/Boolean">Boolean</a> object overrides the <code>toString</code> method of the <a href="/en/JavaScript/Reference/Global_Objects/Object" title="en/JavaScript/Reference/Global_Objects/Object">Object</a> object; it does not inherit <a href="/en/JavaScript/Reference/Global_Objects/Object/toString" title="en/JavaScript/Reference/Global_Objects/Object/toString">Object.toString</a>. For Boolean objects, the <code>toString</code> method returns a string representation of the object.</p>
<p>JavaScript calls the <code>toString</code> method automatically when a Boolean is to be represented as a text value or when a Boolean is referred to in a string concatenation.</p>
<p>For Boolean objects and values, the built-in <code>toString</code> method returns the string "<code>true</code>" or "<code>false</code>" depending on the value of the boolean object. In the following code, <code>flag.toString</code> returns "<code>true</code>".</p>
<pre>var flag = new Boolean(true)
var myVar = flag.toString()
</pre><h3 name="See_Also"> See Also </h3>
<p><a href="en/Core_JavaScript_1.5_Reference/Global_Objects/Object/toString">Object.toString</a>
</p>{{ languages( { "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/Boolean/toString", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/Boolean/toString" } ) }}
Revert to this revision