NaN !== NaN: The Only Value That Isn’t Equal to Itself

📰 Medium · Programming

Learn why NaN is the only value in JavaScript that isn't equal to itself and how to handle it

intermediate Published 12 Apr 2026
Action Steps
  1. Check for NaN using the isNaN() function
  2. Use the Object.is() method to compare values
  3. Test the inequality of NaN with itself using the !== operator
  4. Apply this knowledge to handle NaN values in your JavaScript code
  5. Compare the behavior of NaN with other JavaScript values
Who Needs to Know This

Developers and programmers working with JavaScript will benefit from understanding this unique property of NaN to avoid potential bugs and errors in their code

Key Insight

💡 NaN is not equal to itself in JavaScript, use Object.is() or isNaN() to handle it correctly

Share This
Did you know NaN is the only value in #JavaScript that isn't equal to itself?
Read full article → ← Back to Reads