JavaScript 返回NaN的数学库函数

示例

通常,Math给定非数字参数的函数将返回NaN。

Math.floor("a")

负数的平方根返回NaN,因为Math.sqrt它不支持虚数或复数。

Math.sqrt(-1)