64
rated 0 times
[
65]
[
1]
/ answers: 1 / hits: 17052
/ 13 Years ago, sat, april 16, 2011, 12:00:00
I came across the goog.math.isFiniteNumber
function in the Google Closure Library. What it does is checking whether a given number is both finite and not NaN
.
The underlying code is:
goog.math.isFiniteNumber = function(num) {
return isFinite(num) && !isNaN(num);
};
So, first it checks whether the number is finite using the native isFinite
function, and then does an additional check to make sure the number isn't NaN
using isNaN
.
However, isFinite
already returns false in case the argument is NaN
. So, what advantages does the check for isNaN
provide?
More From » nan