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

O método Number.parseInt() converte um argumento de string e retorna um inteiro da raiz ou base específica.

+ +
{{EmbedInteractiveExample("pages/js/number-parseint.html", "taller")}}
+ + + +

Sintaxe

+ +
Number.parseInt(string,[ radix])
+ +

Parâmetros

+ +
+
+
string
+
O valor a ser convertido. Se este argumento não for uma string, então ele é convertido a um usando a operação abstrata ToString. O espaço em branco inicial neste argumento é ignorado.
+
radix {{optional_inline}}
+
Um inteiro entre 2 e 36 que representa a raiz (a base no sistema numérico matemático) de uma string. Tome cuidado—o padrão não é 10!
+
+
+ +

Valor de retorno

+ +

Um inteiro convertido de uma dada string.

+ +

Se a radix é menor que 2 ou maior que 36, e o primeiro caracter que não é um espaço em branco não puder ser convertido para um número, {{jsxref("NaN")}} é retornado.

+ +

Polyfill

+ +
if (Number.parseInt === undefined) {
+    Number.parseInt = window.parseInt
+}
+
+ +

Exemplos

+ +

Number.parseInt vs parseInt

+ +

Este método tem a mesma funcionalidade que o método global {{jsxref("parseInt", "parseInt()")}}:

+ +
Number.parseInt === parseInt // true
+ +

e é parte do ECMAScript 2015 (sua proposta é a modularização dos globais). Por favor veja {{jsxref("parseInt", "parseInt()")}} para mais detalhes e exemplos.

+ +

Especificações

+ + + + + + + + + + + + +
Especificação
{{SpecName('ESDraft', '#sec-number.parseint', 'Number.parseInt')}}
+ +

Compatibilidade de navegador

+ + + +

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

+ +

Veja também

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