Number.MAX_VALUE
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
A propriedade Number.MAX_VALUE
representa o maior valor numérico representável em JavaScript.
Experimente
function multiply(x, y) {
if (x * y > Number.MAX_VALUE) {
return "Process as Infinity";
}
return x * y;
}
console.log(multiply(1.7976931348623157e308, 1));
// Expected output: 1.7976931348623157e+308
console.log(multiply(1.7976931348623157e308, 2));
// Expected output: "Process as Infinity"
Property attributes of Number.MAX_VALUE | |
---|---|
Writable | no |
Enumerable | no |
Configurable | no |
Descrição
Exemplos
Usando MAX_VALUE
O código a seguir multiplica dois valores numéricos. Se o resultado é menor ou igual a MAX_VALUE
, a função func1
é chamada; caso contrário, a função func2
é chamada.
js
if (num1 * num2 <= Number.MAX_VALUE) {
func1();
} else {
func2();
}
Especificações
Specification |
---|
ECMAScript® 2025 Language Specification # sec-number.max_value |
Compatibilidade com navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MAX_VALUE |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Veja também
Number.MIN_VALUE
- O objeto
Number
a qual ela pertence