Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 841135 of isFinite()

  • Revision slug: Web/JavaScript/Reference/Global_Objects/isFinite
  • Revision title: isFinite()
  • Revision id: 841135
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment
Tags: 

Revision Content

{{jsSidebar("Objects")}}

The global isFinite() function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number.

Syntax

isFinite(testValue)

Parameters

testValue
The value to be tested for finiteness.

Description

isFinite is a top-level function and is not associated with any object.

You can use this function to determine whether a number is a finite number. The isFinite function examines the number in its argument. If the argument is NaN, positive infinity, or negative infinity, this method returns false; otherwise, it returns true.

Examples

isFinite(Infinity);  // false
isFinite(NaN);       // false
isFinite(-Infinity); // false

isFinite(0);         // true
isFinite(2e64);      // true


isFinite("0");       // true, would've been false with the 
                     // more robust Number.isFinite("0")

Specifications

Specification Status Comment
{{SpecName('ES3')}} {{Spec2('ES3')}} Initial definition.
{{SpecName('ES5.1', '#sec-15.1.2.5', 'isFinite')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-isfinite-number', 'isFinite')}} {{Spec2('ES6')}}  

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

See also

  • {{jsxref("Number.isFinite()")}}
  • {{jsxref("Number.NaN()")}}
  • {{jsxref("Number.POSITIVE_INFINITY")}}
  • {{jsxref("Number.NEGATIVE_INFINITY")}}

Revision Source

<div>{{jsSidebar("Objects")}}</div>

<p>The global <code><strong>isFinite()</strong></code> function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
isFinite(<em>testValue</em>)</pre>

<h3 id="Parameters">Parameters</h3>

<dl>
 <dt><code>testValue</code></dt>
 <dd>The value to be tested for finiteness.</dd>
</dl>

<h2 id="Description">Description</h2>

<p><code>isFinite</code> is a top-level function and is not associated with any object.</p>

<p>You can use this function to determine whether a number is a finite number. The <code>isFinite</code> function examines the number in its argument. If the argument is <code>NaN</code>, positive infinity, or negative infinity, this method returns <code>false</code>; otherwise, it returns <code>true</code>.</p>

<h2 id="Examples">Examples</h2>

<pre class="brush: js">
isFinite(Infinity);  // false
isFinite(NaN);       // false
isFinite(-Infinity); // false

isFinite(0);         // true
isFinite(2e64);      // true


isFinite("0");       // true, would've been false with the 
                     // more robust Number.isFinite("0")
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES3')}}</td>
   <td>{{Spec2('ES3')}}</td>
   <td>Initial definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.1.2.5', 'isFinite')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-isfinite-number', 'isFinite')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{jsxref("Number.isFinite()")}}</li>
 <li>{{jsxref("Number.NaN()")}}</li>
 <li>{{jsxref("Number.POSITIVE_INFINITY")}}</li>
 <li>{{jsxref("Number.NEGATIVE_INFINITY")}}</li>
</ul>
Revert to this revision