--- title: Number.POSITIVE_INFINITY slug: Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY tags: - JavaScript - Number - Property translation_of: Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY original_slug: Web/JavaScript/Referencia/Objetos_globales/Number/POSITIVE_INFINITY ---

{{JSRef("Objetos_globales", "Number")}}

Resumen

La propiedad Number.POSITIVE_INFINITY representa el infinito positivo.

No se tiene que crear un objeto {{jsxref("Number")}} para acceder a esta propiedad estática (use Number.POSITIVE_INFINITY).

{{js_property_attributes(0,0,0)}}

Descripción

El valor de Number.POSITIVE_INFINITY es el mismo valor de la propiedad {{jsxref( "Infinity")}} del objeto global.

Este valor tiene un comportamiento ligeramente diferente al infinio matemático:

Muchos métodos de JavaScript (tales como el constructor del objeto Number, parseFloat y parseInt) retornan NaN si el valor especificado en el parámetro es signficativamente mayor a Number.MAX_VALUE.

Podrías utilizar la propiedad Number.POSITIVE_INFINITY para indicar una condición de error que retorne un numero finito en caso de que esto suceda. Note, sin embargo, que isFinite seria mas apropiado en estos casos.

Ejemplo

En el siguiente ejemplo, a la variable bigNumber se le asigna un valor mucho mayor al valor máximo. Cuando la sentencia if es ejecutada, bigNumber tiene el valor "Infinity", por lo cual a bigNumber le es asignado un valor mas manejable antes de continuar.

var bigNumber = Number.MAX_VALUE * 2;
if (bigNumber === Number.POSITIVE_INFINITY) {
 bigNumber = returnFinite();
}

Especificaciones

Especificaciones Estado Comentario
ECMAScript 1st Edition. Implemented in JavaScript 1.1 Estándar Definición inicial.
{{SpecName('ES5.1', '#sec-15.7.3.6', 'Number.POSITIVE_INFINITY')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-number.positive_infinity', 'Number.POSITIVE_INFINITY')}} {{Spec2('ES6')}}  

Compatibilidad con navegadores

{{Compat("javascript.builtins.Number.POSITIVE_INFINITY")}}

Ver también