ES6 - Number.isFinite


Advertisements

Determines whether the passed value is a finite number. Returns true/false.

Syntax

The syntax mentioned below if for Number.isFinite, where, value has to be tested for finiteness.

let res = Number.isFinite(value);

Example

<script>
   console.log(Number.isFinite(Infinity))//false
   console.log(Number.isFinite(-Infinity))//false
   console.log(Number.isFinite(NaN))//false
   console.log(Number.isFinite(123))//true
   console.log(Number.isFinite('123')) // evaluates to false
   console.log(isFinite('123')) // evaluates to true,global function
</script>

The output of the above code will be as follows −

false
false
false
true
false
true
Advertisements