In TypeScript, Number.MAX_VALUE
is a number property that returns the largest number possible in TypeScript. This number exists in JavaScript as well. This is because TypeScript and JavaScript are basically the same, except that TypeScript offers more. Wherever JavaScript runs, TypeScript runs as well.
Number.MAX_VALUE
The value returned by this number property is 1.7976931348623157e+308. Any number value more than this is represented as infinity.
Let's understand this better with a code example below:
// create a number value as highest number valuelet num:number = Number.MAX_VALUE// logout this valueconsole.log(num) // 1.7976931348623157e+308// compare with infinityconsole.log(Number.MAX_VALUE > Number.POSITIVE_INFINITY) // falseconsole.log(Number.MAX_VALUE > Number.NEGATIVE_INFINITY) // true// add another value to itconsole.log(Number.MAX_VALUE * 1000000) // Infinity
Number.MAX_VALUE
. Number.MAX_VALUE
and positive infinity, and then negative infinity.Number.MAX_VALUE
by 1,000,000. This returns an infinity because any number larger than this method is represented as infinity.