无限是javascript中的一些数字?

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

解决方法:

是的,Infinity和-Infinity是special 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类型的值,尽管它是“not a number”的首字母缩写词.

上一篇:算法题


下一篇:2021.4.4java Number typeof语法 最大值 Infinity字面量 字符串相乘 最小值 整数的运算 浮点数计算