What is negative infinity in javascript?

The Number.NEGATIVE_INFINITY property represents the negative Infinity value. Any value that goes over the maximum value is available in JavaScript gets changed to negative infinity.


function checkInfinity(smallNumber) {
   if (smallNumber === Number.NEGATIVE_INFINITY) {
      return 'Process number as -Infinity';
   return smallNumber;
console.log(checkInfinity(-Number.MAX_VALUE * 2));


"Process number as -Infinity"

You can find more details about how this number is processed in javascript at MDN docs:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY

Note − The value of Number.NEGATIVE_INFINITY is the same as the negative value of the global object's Infinity property.