JavaScript(JS) built-in method - isNaN

The isNaN() method in JavaScript is a built-in function that determines whether a passed value is NaN (not a number). It returns a Boolean value indicating whether the provided value is NaN.

The isNaN() function takes one parameter, which is the value to be tested. If the value is a number, isNaN() returns false if the value is a finite number, and true if the value is NaN or if it cannot be converted to a number. If the value is not a number, isNaN() returns true.

Here's an example of using the isNaN() method:

isNaN(42); // false
isNaN(NaN); // true
isNaN("42"); // false
isNaN("Hello"); // true
S‮w:ecruo‬ww.theitroad.com

In the example above, we use the isNaN() method to check if the given values are NaN. The first call to isNaN() returns false because 42 is a finite number. The second call returns true because NaN is not a number. The third call returns false because the string "42" can be converted to the number 42. The fourth call returns true because the string "Hello" cannot be converted to a number.