Quick Programming
Published in

Quick Programming

Working with NaN in JavaScript

And why NaN is not equal to NaN.

Photo by Volkan Olmez on Unsplash

Javascript is a weird language, that is nothing new. But it amazes me how I haven’t seen it all after using Javascript for nearly a decade. I came across an interesting bug that inspired me for this article, I was struggling with a NaN value, and while trying to add a conditional for when the value was NaN I discovered that it’s not equal to NaN.




Development-related articles.

Recommended from Medium

Build Two-factor Authentication in Angular with Twilio Authy

New React Dev Tools, WebKit tracking prevention policy and a preview of V8 v7.7

A Gem and A Script. Which is More Valued?

Refactoring In React

Customizing Axes in D3.js

Why we call 2 .then() on fetch()

How we publish the Klarna Point of Sale app, Part 1/5

Dealing with Ant Design update: Chapter 2 (it seems not to be due to Ant Design version…)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Always learning👨🏻‍🎓. I occasionally write about programming. Follow me on Twitter @0xmbvissers

More from Medium

An Introduction to TypeScript for Beginners

Create dynamic dependant dropdowns with Javascript in Rails 6.1.4

How to Setup and Use Redux with React

Build a Gatsby Blog Post Filter