Tuesday, February 24, 2009

Javascript and NaN

I always seem to forget but you have to use the function isNaN to test javascript variable. I always want to write it wrong with value == NaN...

Here is an example of it (not a great one but a general idea of what's going on):
 var num = Number(v);

if ( isNaN(num)) console.debug("v is not a number");
Such a strange thing that num isn't null or that it doesn't throw an exception. The crazy typing stuff inside of languages :)

1 comment:

  1. CALFRE handles oracle fusion financials online training and its modules maintaining classroom based training with
    the self-paced videos. An expert having ten plus years of self-experience handles the training period through
    online and explains each and every point perfectly. We recently launched our institute in the USA and getting
    the best reputation over there.



    Oracle fusion Financials Online Training in Ameerpet

    Oracle Fusion Financials Training in Ameerpet

    ReplyDelete