javascript - 无穷大是javascript中的某个数字吗?

标签 javascript infinity

alert(1/0) 警报 Infinityalert(1/-0) 警报 -Infinity . alert(-1/-0) 提醒 Infinity,正如我在使用 实数 进行一些操作时所期望的那样。我不能说无穷大是一个可测量的值。 javascript 是否认为它是某个数字?

最佳答案

是的,Infinity-Infinityspecial values of the Number type .来自 ES5 规范:

There are two other special values, called positive Infinity and negative Infinity. For brevity, these values are also referred to for expository purposes by the symbols +∞ and −∞, respectively. (Note that these two infinite Number values are produced by the program expressions +Infinity (or simply Infinity) and -Infinity.)

另请注意,NaN 也是 Number 类型的值,尽管它是“非数字”的首字母缩写词。

关于javascript - 无穷大是javascript中的某个数字吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24166320/

相关文章:

c++ - 我应该选择 HUGE_VAL 还是 INFINITY?

javascript - 为什么在 if 条件为 false 的情况下提交表单?

javascript - 如何根据变量的存在来更改 .keyup ?

javascript - Angular 2 ng2-redux 和 ngrx/store

javascript - dojo 图表 - 轴标签不适合图表

javascript - 尝试在数组中查找最接近的数字会导致 -Infinity JavaScript

javascript - 我应该使用什么 Meteor 事件处理程序来提交 onchange 表单

perl - 检查 Perl 模块中无穷大的最佳方法是什么?

java - Math.isFinite() 方法的实现

perl - 如何在 Perl 中创建或测试 NaN 或无穷大?