From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- .../number/positive_infinity/index.html | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 files/pt-br/web/javascript/reference/global_objects/number/positive_infinity/index.html (limited to 'files/pt-br/web/javascript/reference/global_objects/number/positive_infinity') diff --git a/files/pt-br/web/javascript/reference/global_objects/number/positive_infinity/index.html b/files/pt-br/web/javascript/reference/global_objects/number/positive_infinity/index.html new file mode 100644 index 0000000000..b6ac31f1ec --- /dev/null +++ b/files/pt-br/web/javascript/reference/global_objects/number/positive_infinity/index.html @@ -0,0 +1,92 @@ +--- +title: Number.POSITIVE_INFINITY +slug: Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY +translation_of: Web/JavaScript/Reference/Global_Objects/Number/POSITIVE_INFINITY +--- +
{{JSRef}}
+ +

A propriedade Number.POSITIVE_INFINITY representa o valor positivo infinito.

+ +

Você não precisa criar um objeto {{jsxref("Number")}} para utilizar a propriedade estática (use Number.POSITIVE_INFINITY).

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

Descrição

+ +

O valor de Number.POSITIVE_INFINITY é o mesmo valor da propriedade {{jsxref("Infinity")}} do objeto global.

+ +

Esse valor se comporta ligeiramente diferente do infinito matemático:

+ + + +

Você pode usar a propriedade Number.POSITIVE_INFINITY para indicar uma condição de erro que retorna um número finito no caso de sucesso. Sobretudo, {{jsxref("isFinite")}} seria mais apropriado nesse caso.

+ +

Exemplos

+ +

Usando POSITIVE_INFINITY

+ +

No exemplo a seguir, a variável bigNumber recebe um valor maior que o valor máximo. Quando as declarações {{jsxref("Statements/if...else", "if")}} executam, bigNumber tem o valor Infinity, então bigNumber recebe um valor mais gerenciável antes de continuar.

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

Especificação

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EspecificaçãoStatusComentário
{{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.1.
{{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')}} 
{{SpecName('ESDraft', '#sec-number.positive_infinity', 'Number.POSITIVE_INFINITY')}}{{Spec2('ESDraft')}} 
+ +

Compatibilidade dos browsers

+ + + +

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

+ +

Ver também

+ + -- cgit v1.2.3-54-g00ecf