Why check for !isNaN() after isFinite()?

The only difference is this:

!isNan(1/0) // --> true
isFinite(1/0) // --> false

isNaN checks whether the argument is a number or not. The Infinities (+/-) are also numerical, thus they pass the isNaN check, but don’t pass the isFinite check.

** Note that any string which can be parsed as a number (“2”, “3.14”) will cause isNaN to return false.

Hope this helps.

PS: The answer given by user1170379 was very nearly perfect.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)