I recently saw the Infinity
Number used to set a max number of listeners for an event emitter in node.
Infinity
has some interesting behavior associated with it. If multiplied/added/subtracted by any other number its result will be Infinity
. This seems like it would cause unexpected/unwanted behavior if ever used.
Why is it even in the spec? here In what case would you ever need to use Infinity
? What was the purpose of creating it in the language?
In this question here there is a use case that uses it to find a max number from a list of numbers. Although this example works, the Infinity
value is not needed to accomplish the task. It could be done very easily without it.