From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../number/positive_infinity/index.html | 130 +++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/number/positive_infinity/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/number/positive_infinity') diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/positive_infinity/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/positive_infinity/index.html new file mode 100644 index 0000000000..4207e72e5a --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/number/positive_infinity/index.html @@ -0,0 +1,130 @@ +--- +title: Number.POSITIVE_INFINITY +slug: Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY +translation_of: Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY +--- +
{{JSRef("Global_Objects", "Number")}}
+ +

概述

+ +

Number.POSITIVE_INFINITY 属性表示正无穷大。

+ +

不必创建一个 {{jsxref("Global_Objects/Number", "Number")}} 实例,可使用 Number.POSITIVE_INFINITY 来访问该静态属性。

+ +

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

+ +

描述

+ +

Number.POSITIVE_INFINITY 的值同全局对象 {{jsxref("Global_Objects/Infinity", "Infinity")}} 属性的值相同。

+ +

该值的表现同数学上的无穷大有点儿不同:

+ + + +

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 {{jsxref("Global_Objects/isFinite", "isFinite")}} would be more appropriate in such a case.

+ +

示例

+ +

下例中,赋值给变量 bigNumber 一个大于 JavaScript 中最大值的值。当 if 语句执行时,变量 bigNumber 值为 "Infinity", 因此在继续执行代码前,为变量 bigNumber 设置一个容易管理的值。

+ +
var bigNumber = Number.MAX_VALUE * 2
+if (bigNumber == Number.POSITIVE_INFINITY) {
+ bigNumber = returnFinite();
+}
+
+ +

规范

+ + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
ECMAScript 1st Edition. Implemented in JavaScript 1.1StandardInitial definition.
{{SpecName('ES5.1', '#sec-15.7.3.6', 'Number.POSITIVE_INFINITY')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-number.positive_infinity', 'Number.POSITIVE_INFINITY')}}{{Spec2('ES6')}} 
+ +

浏览器兼容性

+ +

{{ CompatibilityTable() }}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
+
+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf