| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Number | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 ..
Number , 37 -9,25.
Number . Number().
255; //
255.0; //
255 === 255.0; // true
255 === 0xff; // true ( )
255 === 0b11111111; // true ( )
255 === 0.255e3; // true ( )
JavaScript (, 37) , . . JavaScript BigInt, Number . 37 , BigInt.
Number(value) . , NaN.
Number("123"); // 123
Number("123") === 123; // true
Number("unicorn"); // NaN
Number(undefined); // NaN
Number() Number.
Number ( new), Number, . , typeof new Number(42) === "object" new Number(42) !== 42 ( new Number(42) == 42).
:
Number .
Number.EPSILON.
Number.MAX_SAFE_INTEGER, JavaScript (253 - 1).
Number.MAX_VALUE.
Number.MIN_SAFE_INTEGER, JavaScript (-(253 - 1)).
Number.MIN_VALUE, ( ).
Number.NaN, .
Number.NEGATIVE_INFINITY. .
Number.POSITIVE_INFINITY. .
Number.isFinite(), .
Number.isInteger(), .
Number.isNaN(), NaN.
Number.isSafeInteger(), ( -(253 - 1) 253 - 1).
Number.parseFloat() , parseFloat().
Number.parseInt() , parseInt().
Number.prototype Number.
Number.prototype.constructor-, . Number Number.
Number.prototype.toExponential(), .
Number.prototype.toFixed(), .
Number.prototype.toLocaleString()Number.prototype.toPrecision(), .
Number.prototype.toString()Number.prototype.valueOf()Number Number :
const biggestNum = Number.MAX_VALUE;
const smallestNum = Number.MIN_VALUE;
const infiniteNum = Number.POSITIVE_INFINITY;
const negInfiniteNum = Number.NEGATIVE_INFINITY;
const notANum = Number.NaN;
Number , Number.
const biggestInt = Number.MAX_SAFE_INTEGER; // (2**53 - 1) => 9007199254740991
const smallestInt = Number.MIN_SAFE_INTEGER; // -(2**53 - 1) => -9007199254740991
JSON , , , , JSON Number.
Number() Date Date Number :
const d = new Date("1995-12-17T03:24:00");
console.log(Number(d));
819199440000.
Number("123"); // 123
Number("123") === 123; // true
Number("12.3"); // 12.3
Number("12.00"); // 12
Number("123e-1"); // 12.3
Number(""); // 0
Number(null); // 0
Number("0x11"); // 17
Number("0b11"); // 3
Number("0o11"); // 9
Number("foo"); // NaN
Number("100a"); // NaN
Number("-Infinity"); // -Infinity
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-number-objects |
This page was last modified on 11 . 2024 . by MDN contributors.
NumberObject/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |