Tiny tip for NaN use

Use case:

//you have a number in text format and you want to convert it to number format
//and also to make sure there is no character inside
var nTemp:Number = Number(someStringWithCharactersInsideProbably);
if (isNan(nTemp))
{
//aha.. there are some characters inside
}

//and what I wanted to point out..
//This won’t work

/*
if (nTemp == NaN)
{
//aha
}
*/

This entry was posted in Adobe Flash, as3, Coding faults collection. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *