From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- .../reference/errors/not_a_codepoint/index.html | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 files/pt-br/web/javascript/reference/errors/not_a_codepoint/index.html (limited to 'files/pt-br/web/javascript/reference/errors/not_a_codepoint') diff --git a/files/pt-br/web/javascript/reference/errors/not_a_codepoint/index.html b/files/pt-br/web/javascript/reference/errors/not_a_codepoint/index.html new file mode 100644 index 0000000000..7e0c85bf8d --- /dev/null +++ b/files/pt-br/web/javascript/reference/errors/not_a_codepoint/index.html @@ -0,0 +1,56 @@ +--- +title: 'RangeError: argument is not a valid code point' +slug: Web/JavaScript/Reference/Errors/Not_a_codepoint +tags: + - Erros + - JavaScript + - RangeError +translation_of: Web/JavaScript/Reference/Errors/Not_a_codepoint +--- +
{{jsSidebar("Errors")}}
+ +

Mensagem

+ +
RangeError: Invalid code point {0} (Edge)
+RangeError: {0} is not a valid code point (Firefox)
+RangeError: Invalid code point {0} (Chrome)
+
+ + + +

Tipo de Erro

+ +

{{jsxref("RangeError")}}

+ +

O que está errado?

+ +

{{jsxref("String.fromCodePoint()")}} dispara esse erro quando são passados valores {{jsxref("NaN")}}, inteiros negativos (-1), não inteiros (5.4), ou valores maiores que 0x10FFFF (1114111).

+ +

Um code point é um valor Unicode; isto é,é um valor inteiro entre 0 e 0x10FFFF.

+ +

Exemplos

+ +

Errado

+ +
String.fromCodePoint('_');      // RangeError
+String.fromCodePoint(Infinity); // RangeError
+String.fromCodePoint(-1);       // RangeError
+String.fromCodePoint(3.14);     // RangeError
+String.fromCodePoint(3e-2);     // RangeError
+String.fromCodePoint(NaN);      // RangeError
+ +

Certo

+ +
String.fromCodePoint(42);       // "*"
+String.fromCodePoint(65, 90);   // "AZ"
+String.fromCodePoint(0x404);    // "\u0404"
+String.fromCodePoint(0x2F804);  // "\uD87E\uDC04"
+String.fromCodePoint(194564);   // "\uD87E\uDC04"
+String.fromCodePoint(0x1D306, 0x61, 0x1D307) // "\uD834\uDF06a\uD834\uDF07"
+
+ +

Veja também

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