Infinity & NaN Back

  • JavaScript does not raise errors in case of overflow, underflow, or devision by zero, there is a special not-a-number value: NaN.
  • JavaScript predefines global variables Infinity to distinguished from NaN.
  • Infinity is read/write in ECMAScript3, while read/only in ECMAScript5.
//Positive Infinity
Infinity    
Number.POSITIVE_INFINITY    
1/0
Number.MAX_VALUE + 1

//Negative Infinity
-Infinity
Number.NEGATIVE_INFINITY
-1/0        
-Number.MAX_VALUE - 1        

//NaN
NaN
Number.NaN
0/0

isNaN(x);    //return true when x is NaN
isFinite(x);    //return true when x is other than NaN, Positive or Negative Infinity
Empty Comments
Sign in GitHub

As the plugin is integrated with a code management system like GitLab or GitHub, you may have to auth with your account before leaving comments around this article.

Notice: This plugin has used Cookie to store your token with an expiration.