« 1234567890 | Main | Active Support and JSON gems don't play nice »

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341c8db453ef011168f02631970c

Listed below are links to weblogs that reference isNaN gotcha in JavaScript:

Comments

DavidLG

This is easily explained. isNaN is meant to be called on a number, so "" and null get coerced to 0 before the test for NaN is even done (the same as when you do (+x) or Number(x) on one of these values). parseInt, on the other hand, takes a string, and does not successfully parse "" or "null" as integers.

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment