1/**
2* Number.isNaN is almost identical to ES5 global isNaN method.
3* Number.isNaN returns whether the provided value equals NaN.
4* This is a very different question from “is this not a number?”.
5*/
6
7Number.isNaN({}); // <- false, {} is not NaN
8Number.isNaN('ponyfoo') // <- false, 'ponyfoo' is not NaN
9Number.isNaN(NaN) // <- true, NaN is NaN
10Number.isNaN('pony'/'foo') // <- true, 'pony'/'foo' is NaN, NaN is NaN
11
12isNaN({}); // <- true, {} is not a number
13isNaN('ponyfoo'); // <- true, 'ponyfoo' is not a number
14isNaN(NaN); // <- true, NaN is not a number
15isNaN('pony'/'foo'); // <- true, 'pony'/'foo' is NaN, NaN is not a number
1// Use isNaN()
2// In javascript compare NaN direct alweys return false
3let num1 = Number("Vishal");
4
5// This code never work
6if(num1 == NaN){ // Direct compare NaN alweys return false so use isNaN() function
7 ....... Your Code .......
8}
9
10// This code work
11if(isNaN(num1){
12 .........Your Code .......
13}
14
1 var s = userInput[0];
2 if(isNaN(s) !== true)
3 {
4 console.log("yes");
5 }
6 else
7 {
8 console.log("no");
9 }
1 var j ="Hello World" // isNaN (j) returns true
2 var n = 15; // isNaN (n) returns false
3
4 if(isNaN(n) == true) // NaN means >> Not a Number
5 {
6 console.log("yes, it's a string");
7 }
8 else
9 {
10 console.log("no, it's a number");
11 }
1let b=1
2let n=readline()
3if(isNaN(b)){
4 console.log("You typed 0!")
5}else{
6 console.log("You did not type 0!")
7}