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

后端 未结 5 1001
你的背包
你的背包 2021-02-01 17:04

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<

5条回答
  •  渐次进展
    2021-02-01 17:41

    isNaN() returns true if the argument is not a number or if the argument is a non-numeric value such as a string or an object.Otherwise, It returns false. Example: isNaN(0/0) =>true; isNaN(2-1) =>false; isFinite() returns true if the argument is a number other than NaN,Infinity or -Infinity.Otherwise, It returns false. Example: isFinite("2000") =>false; isFinite(200/2) =>true;`

提交回复
热议问题