Tag: javascript troubleshooting datatypes number NaN testing

Javascript testing for NaN: why doesn’t !=”NaN” work?

A couple of weeks ago, I was working on a custom HTML wrapper for Captivate quizzes that would behave one way if a score were already stored for that quiz, and another if the score were non-existent or zero.

So, how best to test for the existence of a score? Usually I test for the existence of a value with


if (typeof foo != "undefined"){do something}

Continue reading