Open In App

What is the use of the NaN Value in JavaScript ?

In JavaScript, NaN stands for “Not a Number.” It is a special value that represents the result of an operation that cannot produce a meaningful numerical result. The purpose NaN is to indicate when a value is not a valid number according to the JavaScript specification.

Example: Here, we attempt to perform the division operation "Hello" / 2. Since dividing a string by a number is not a valid arithmetic operation, JavaScript returns NaN as the result.




const result = "Hello" / 2;
console.log(result);

Output
NaN
Article Tags :