{{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}} |