Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 709481 of Number.prototype

  • Revision slug: Web/JavaScript/Reference/Global_Objects/Number/prototype
  • Revision title: Number.prototype
  • Revision id: 709481
  • Created:
  • Creator: Markus Prokott
  • Is current revision? No
  • Comment

Revision Content

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

Summary

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

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

Description

All {{jsxref("Global_Objects/Number", "Number")}} instances inherit from Number.prototype. The prototype object of the {{jsxref("Global_Objects/Number", "Number")}} constructor can be modified to affect all {{jsxref("Global_Objects/Number", "Number")}} instances.

Properties

Number.prototype.constructor
Returns the function that created this object's instance. By default this is the {{jsxref("Global_Objects/Number", "Number")}} object.
{{jsOverrides("Object", "properties", "constructor")}}

Methods

{{jsxref("Number.prototype.toExponential()")}}
Returns a string representing the number in exponential notation.
{{jsxref("Number.prototype.toFixed()")}}
Returns a string representing the number in fixed-point notation.
{{jsxref("Number.prototype.toLocaleString()")}}
Returns a string with a language sensitive representation of this number. Overrides the {{jsxref("Object.prototype.toLocaleString()")}} method.
{{jsxref("Number.prototype.toPrecision()")}}
Returns a string representing the number to a specified precision in fixed-point or exponential notation.
{{jsxref("Number.prototype.toSource()")}} {{non-standard_inline}}
Returns an object literal representing the specified {{jsxref("Global_Objects/Number", "Number")}} object; you can use this value to create a new object. Overrides the {{jsxref("Object.prototype.toSource()")}} method.
{{jsxref("Number.prototype.toString()")}}
Returns a string representing the specified object in the specified radix (base). Overrides the {{jsxref("Object.prototype.toString()")}} method.
{{jsxref("Number.prototype.valueOf()")}}
Returns the primitive value of the specified object. Overrides the {{jsxref("Object.prototype.valueOf()")}} method.
{{jsOverrides("Object", "methods", "toExponential", "toFixed", "toLocaleString", "toPrecision", "toSource", "toString", "valueOf")}}

Specifications

Specification Status Comment
ECMAScript 1st Edition. Standard Initial definition. Implemented in JavaScript 1.1.
{{SpecName('ES5.1', '#sec-15.7.4', 'Number')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-properties-of-the-number-prototype-object', 'Number')}} {{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", "Number")}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <strong><code>Number.prototype</code></strong> property represents the prototype for the {{jsxref("Global_Objects/Number", "Number")}} constructor.</p>
<div>
 {{js_property_attributes(0, 0, 0)}}</div>
<h2 id="Description" name="Description">Description</h2>
<p>All {{jsxref("Global_Objects/Number", "Number")}} instances inherit from <code>Number.prototype</code>. The prototype object of the {{jsxref("Global_Objects/Number", "Number")}} constructor can be modified to affect all {{jsxref("Global_Objects/Number", "Number")}} instances.</p>
<h2 id="Properties">Properties</h2>
<dl>
 <dt>
  <code>Number.prototype.constructor</code></dt>
 <dd>
  Returns the function that created this object's instance. By default this is the {{jsxref("Global_Objects/Number", "Number")}} object.</dd>
</dl>
<div>
 {{jsOverrides("Object", "properties", "constructor")}}</div>
<h2 id="Methods">Methods</h2>
<dl>
 <dt>
  {{jsxref("Number.prototype.toExponential()")}}</dt>
 <dd>
  Returns a string representing the number in exponential notation.</dd>
 <dt>
  {{jsxref("Number.prototype.toFixed()")}}</dt>
 <dd>
  Returns a string representing the number in fixed-point notation.</dd>
 <dt>
  {{jsxref("Number.prototype.toLocaleString()")}}</dt>
 <dd>
  Returns a string with a language sensitive representation of this number. Overrides the {{jsxref("Object.prototype.toLocaleString()")}} method.</dd>
 <dt>
  {{jsxref("Number.prototype.toPrecision()")}}</dt>
 <dd>
  Returns a string representing the number to a specified precision in fixed-point or exponential notation.</dd>
 <dt>
  {{jsxref("Number.prototype.toSource()")}} {{non-standard_inline}}</dt>
 <dd>
  Returns an object literal representing the specified {{jsxref("Global_Objects/Number", "Number")}} object; you can use this value to create a new object. Overrides the {{jsxref("Object.prototype.toSource()")}} method.</dd>
 <dt>
  {{jsxref("Number.prototype.toString()")}}</dt>
 <dd>
  Returns a string representing the specified object in the specified radix (base). Overrides the {{jsxref("Object.prototype.toString()")}} method.</dd>
 <dt>
  {{jsxref("Number.prototype.valueOf()")}}</dt>
 <dd>
  Returns the primitive value of the specified object. Overrides the {{jsxref("Object.prototype.valueOf()")}} method.</dd>
</dl>
<div>
 {{jsOverrides("Object", "methods", "toExponential", "toFixed", "toLocaleString", "toPrecision", "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.</td>
   <td>Standard</td>
   <td>Initial definition. Implemented in JavaScript 1.1.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.7.4', 'Number')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-properties-of-the-number-prototype-object', 'Number')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div>
 {{CompatibilityTable}}</div>
<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