Number.NaN

Number.NaN 静态数据属性代表 Not-A-Number,相当于 NaN。有关 NaN 行为的更多信息,请参阅 全局属性的描述

¥The Number.NaN static data property represents Not-A-Number, which is equivalent to NaN. For more information about the behaviors of NaN, see the description for the global property.

Try it

¥Value

数值 NaN

¥The number value NaN.

Property attributes of Number.NaN
Writable no
Enumerable no
Configurable no

描述

¥Description

由于 NaNNumber 的静态属性,因此你始终将其用作 Number.NaN,而不是作为数字值的属性。

¥Because NaN is a static property of Number, you always use it as Number.NaN, rather than as a property of a number value.

示例

¥Examples

检查值是否为数字

¥Checking whether values are numeric

js
function sanitize(x) {
  if (isNaN(x)) {
    return Number.NaN;
  }
  return x;
}

规范

Specification
ECMAScript Language Specification
# sec-number.nan

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看

¥See also