這是表示大于Number.MAX_VALUE任何值的特殊數值。此值被表示為“無限大”。此值類似于在其數學的無窮大。例如,任何事情乘以POSITIVE_INFINITY結果就是POSITIVE_INFINITY,以及任何除以POSITIVE_INFINITY的結果都為零。
因為POSITIVE_INFINITY是一個常數,它是只讀屬性。
語法
您可以使用以下語法訪問屬性:
var val = Number.POSITIVE_INFINITY;
例子:
這里有一個例子說明這個屬性的用法:
<html><head><script type="text/javascript"><!--function showValue(){ var bigNumber = Number.MAX_VALUE * 2 if (bigNumber == Number.POSITIVE_INFINITY) { alert("Value of bigNumber : " + bigNumber ); }}//--></script></head><body><p>Click the following to see the result:</p><form><input type="button" value="Click Me" onclick="showValue();" /></form></body></html>這將產生以下結果:
Value of val : Infinity
新聞熱點
疑難解答