Infinity
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.
La propiedad global Infinity
es un valor numérico que representa el infinito.
Pruébalo
const maxNumber = Math.pow(10, 1000); // Max positive number
if (maxNumber === Infinity) {
console.log("Let's call it Infinity!");
// Expected output: "Let's call it Infinity!"
}
console.log(1 / maxNumber);
// Expected output: 0
Valor
El mismo valor numérico que Number.POSITIVE_INFINITY
.
Atributos de la propiedad Infinity | |
---|---|
Sobrescribir | No |
Numerable | No |
Configurable | No |
Descripción
Infinity
es una propiedad del objeto global. En otras palabras, es una variable de alcance global.
El valor Infinity
(infinito positivo) es mayor que cualquier otro número.
Este valor se comporta de forma ligeramente diferente al infinito matemático; consulte Number.POSITIVE_INFINITY
para obtener más información.
Ejemplos
Utilizando Infinity
console.log(Infinity); /* Infinity */
console.log(Infinity + 1); /* Infinity */
console.log(Math.pow(10, 1000)); /* Infinity */
console.log(Math.log(0)); /* -Infinity */
console.log(1 / Infinity); /* 0 */
console.log(1 / 0); /* Infinity */
Especificaciones
Specification |
---|
ECMAScript® 2025 Language Specification # sec-value-properties-of-the-global-object-infinity |
Compatibilidad con navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Infinity |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support