Apply your JS skills to key Mozilla projects as an MDN Fellow! http://mzl.la/MDNFellowship

mozilla

Revision 88456 of Boolean.prototype.toString()

  • Revision slug: JavaScript/Reference/Global_Objects/Boolean/toString
  • Revision title: toString
  • Revision id: 88456
  • Created:
  • Creator: evilpie
  • Is current revision? No
  • Comment 3 words added, 7 words removed

Revision Content

Returns a string representing the specified Boolean object.

Method of Boolean
Implemented in 1.1
ECMAScript Edition ECMAScript 1st Edition

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>
<p>Returns a string representing the specified Boolean object.</p>
<table class="standard-table"> <thead> <tr> <th class="header" colspan="2">Method of <a href="/en/JavaScript/Reference/Global_Objects/Boolean"><code>Boolean</code></a></th> </tr> </thead> <tbody> <tr> <td>Implemented in</td> <td>1.1</td> </tr> <tr> <td>ECMAScript Edition</td> <td>ECMAScript 1st Edition</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