Open In App

What is the use of the NaN Value in JavaScript ?

Last Updated : 15 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

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.

Javascript




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


Output

NaN

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads