alert(1/0)
alerts Infinity
and alert(1/-0)
alerts -Infinity
. alert(-1/-0)
alerts Infinity
, as I could expect when doing some operations with real numbers. I can't say that infinity is a measurable value. Does javascript think it is some number?
Yes, Infinity
and -Infinity
are special values of the Number type. From the ES5 spec:
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 simplyInfinity
) and-Infinity
.)
Also note that NaN
is a value of the Number type too, despite it being an acronym for "not a number".