Boolean.prototype

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Boolean/prototype
  • Revision title: Boolean.prototype
  • Revision id: 487411
  • Created:
  • Creator: fscholz
  • Is current revision? Yes
  • Comment

Revision Content

{{JSRef("Global_Objects", "Boolean")}}

Summary

The Boolean.prototype property represents the prototype for the {{jsxref("Global_Objects/Boolean", "Boolean")}} constructor.

{{js_property_attributes(0,0,0)}}

Description

{{jsxref("Global_Objects/Boolean", "Boolean")}} instances inherit from {{jsxref("Boolean.prototype")}}. You can use the constructor's prototype object to add properties or methods to all Boolean instances.

Properties

Boolean.prototype.constructor
Returns the function that created an instance's prototype. This is the {{jsxref("Global_Objects/Boolean", "Boolean")}} function by default.
{{ jsOverrides("Object", "properties", "constructor") }}

Methods

{{jsxref("Boolean.prototype.toSource()")}} {{ Non-standard_inline() }}
Returns a string containing the source of the {{jsxref("Global_Objects/Boolean", "Boolean")}} object; you can use this string to create an equivalent object. Overrides the {{jsxref("Object.prototype.toSource()")}} method.
{{jsxref("Boolean.prototype.toString()")}}
Returns a string of either "true" or "false" depending upon the value of the object. Overrides the {{jsxref("Object.prototype.toString()")}} method.
{{jsxref("Boolean.prototype.valueOf()")}}
Returns the primitive value of the {{jsxref("Global_Objects/Boolean", "Boolean")}} object. Overrides the {{jsxref("Object.prototype.valueOf()")}} method.
{{ jsOverrides("Object", "methods", "toSource", "toString", "valueOf") }}

Specifications

Specification Status Comment
ECMAScript 1st Edition. Implemented in JavaScript 1.0 Standard Initial definition.
{{SpecName('ES5.1', '#sec-15.6.3.1', 'Boolean.prototype')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-boolean.prototype', 'Boolean.prototype')}} {{Spec2('ES6')}}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}

 

Revision Source

<div>
 {{JSRef("Global_Objects", "Boolean")}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <strong><code>Boolean.prototype</code></strong> property represents the prototype for the {{jsxref("Global_Objects/Boolean", "Boolean")}} constructor.</p>
<div>
 {{js_property_attributes(0,0,0)}}</div>
<h2 id="Description" name="Description">Description</h2>
<p>{{jsxref("Global_Objects/Boolean", "Boolean")}} instances inherit from {{jsxref("Boolean.prototype")}}. You can use the constructor's prototype object to add properties or methods to all <code>Boolean</code> instances.</p>
<h2 id="Properties">Properties</h2>
<dl>
 <dt>
  <code>Boolean.prototype.constructor</code></dt>
 <dd>
  Returns the function that created an instance's prototype. This is the {{jsxref("Global_Objects/Boolean", "Boolean")}} function by default.</dd>
</dl>
<div>
 {{ jsOverrides("Object", "properties", "constructor") }}</div>
<h2 id="Methods">Methods</h2>
<dl>
 <dt>
  {{jsxref("Boolean.prototype.toSource()")}} {{ Non-standard_inline() }}</dt>
 <dd>
  Returns a string containing the source of the {{jsxref("Global_Objects/Boolean", "Boolean")}} object; you can use this string to create an equivalent object. Overrides the {{jsxref("Object.prototype.toSource()")}} method.</dd>
 <dt>
  {{jsxref("Boolean.prototype.toString()")}}</dt>
 <dd>
  Returns a string of either "true" or "false" depending upon the value of the object. Overrides the {{jsxref("Object.prototype.toString()")}} method.</dd>
 <dt>
  {{jsxref("Boolean.prototype.valueOf()")}}</dt>
 <dd>
  Returns the primitive value of the {{jsxref("Global_Objects/Boolean", "Boolean")}} object. Overrides the {{jsxref("Object.prototype.valueOf()")}} method.</dd>
</dl>
<div>
 {{ jsOverrides("Object", "methods", "toSource", "toString", "valueOf") }}</div>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>ECMAScript 1st Edition. Implemented in JavaScript 1.0</td>
   <td>Standard</td>
   <td>Initial definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.6.3.1', 'Boolean.prototype')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-boolean.prototype', 'Boolean.prototype')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Chrome for Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Mobile</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<p>&nbsp;</p>
Revert to this revision