ES6 - Number.isNaN



This function returns true if the given value is Not-a-Number (NaN) and its type is Number; otherwise, it returns false.

Syntax

Below mentioned is the syntax for the function Number.isNaN, where value is the number to determine if it is a NaN.

var res = Number.isNaN(value);

Example

<script>
   console.log(Number.isNaN('123'))//false
   console.log(Number.isNaN(NaN))//true
   console.log(Number.isNaN(0/0))//true
</script>

The output of the above code will be as shown below −

false
true
true
Advertisements