Number.POSITIVE_INFINITY
特性表示正无穷大值。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
特性属性在
Number.POSITIVE_INFINITY
|
|
|---|---|
| 可写 | no |
| 可枚举 | no |
| 可配置 | no |
值
Number.POSITIVE_INFINITY
是相同值的全局对象
Infinity
特性。
This value behaves slightly differently than mathematical infinity:
POSITIVE_INFINITY
, multiplied by
POSITIVE_INFINITY
is
POSITIVE_INFINITY
.
NEGATIVE_INFINITY
, multiplied by
POSITIVE_INFINITY
is
NEGATIVE_INFINITY
.
POSITIVE_INFINITY
is positive Zero.
POSITIVE_INFINITY
is negative Zero.
POSITIVE_INFINITY
is
NaN
.
NaN
multiplied by
POSITIVE_INFINITY
is
NaN
.
POSITIVE_INFINITY
, divided by any negative value except
NEGATIVE_INFINITY
, is
NEGATIVE_INFINITY
.
POSITIVE_INFINITY
, divided by any positive value except
POSITIVE_INFINITY
, is
POSITIVE_INFINITY
.
POSITIVE_INFINITY
, divided by either
NEGATIVE_INFINITY
or
POSITIVE_INFINITY
, is
NaN
.
You might use the
Number.POSITIVE_INFINITY
property to indicate an error condition that returns a finite number in case of success. Note, however, that
isFinite
would be more appropriate in such a case.
因为
POSITIVE_INFINITY
is a static property of
Number
, you always use it as
Number.POSITIVE_INFINITY
, rather than as a property of a
Number
object you created.
POSITIVE_INFINITY
In the following example, the variable
bigNumber
is assigned a value that is larger than the maximum value. When the
if
statement executes,
bigNumber
has the value
Infinity
, so
bigNumber
is set to a more manageable value before continuing.
var bigNumber = Number.MAX_VALUE * 2;
if (bigNumber == Number.POSITIVE_INFINITY) {
bigNumber = returnFinite();
}
| 规范 |
|---|
|
ECMAScript (ECMA-262)
在该规范中的 Number.POSITIVE_INFINITY 定义。 |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
更新 GitHub 上的兼容性数据| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
POSITIVE_INFINITY
|
Chrome 1 | Edge 12 | Firefox 1 | IE 4 | Opera 3 | Safari 1 | WebView Android 1 | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 1 | Samsung Internet Android 1.0 | nodejs 0.1.100 |
完整支持
Number
Number.isFinite()
Number.isInteger()
Number.isNaN()
Number.isSafeInteger()
Number.parseFloat()
Number.parseInt()
Number.prototype.toExponential()
Number.prototype.toFixed()
Number.prototype.toLocaleString()
Number.prototype.toPrecision()
Number.prototype.toSource()
Number.prototype.toString()
Number.prototype.valueOf()
Function
Object
Object.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.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.setPrototypeOf()