From cb9e359a51c3249d8f5157db69d43fd413ddeda6 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:45:12 +0100 Subject: unslug ca: move --- .../global_objects/string/fromcharcode/index.html | 126 +++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 files/ca/web/javascript/reference/global_objects/string/fromcharcode/index.html (limited to 'files/ca/web/javascript/reference/global_objects/string/fromcharcode/index.html') diff --git a/files/ca/web/javascript/reference/global_objects/string/fromcharcode/index.html b/files/ca/web/javascript/reference/global_objects/string/fromcharcode/index.html new file mode 100644 index 0000000000..f4e2308bf9 --- /dev/null +++ b/files/ca/web/javascript/reference/global_objects/string/fromcharcode/index.html @@ -0,0 +1,126 @@ +--- +title: String.fromCharCode() +slug: Web/JavaScript/Referencia/Objectes_globals/String/fromCharCode +translation_of: Web/JavaScript/Reference/Global_Objects/String/fromCharCode +--- +
{{JSRef}}
+ +

El mètode estàtic String.fromCharCode() retorna un string creat a partir de la seqüència de valors Unicode especificada.

+ +

Sintaxi

+ +
String.fromCharCode(num1[, ...[, numN]])
+ +

Paràmetres

+ +
+
num1, ..., numN
+
Una seqüència de nombres que són valors Unicode.
+
+ +

Descripció

+ +

Aquest mètode retorna un string i no un objecte de tipus {{jsxref("String")}}.

+ +

Com que fromCharCode() és un mètode estàtic de {{jsxref("String")}}, sempre s'utilitza com String.fromCharCode() en comptes de com un mètode d'un objecte {{jsxref("String")}} creat.

+ +

Exemples

+ +

Utilitzar fromCharCode()

+ +

L'exemple següent retorna el string "ABC".

+ +
String.fromCharCode(65, 66, 67);  // "ABC"
+
+ +

Fer que funcioni amb valors més grans

+ +

Tot i que la majoria dels valors Unicode es poden representar amb un nombre de 16 bits (tal i com s'esperava mentre s'estava estandaritzant el JavaScript) i es pot emprar fromCharCode() per a retornar un sol caràcter per als valors més comuns (com ara valors UCS-2, que són un subconjunt de l'UTF-16 amb els caràcters més comuns), per a poder manegar TOTS els valors legals Unicode (els quals requereixen fins a 21 bits),  l'ús de només fromCharCode() no és adequat ja que els caràcters de valor més alt utilitzen dos nombres "substituts" (de menor valor) per a formar un sol caràcter. Es pot emprar {{jsxref("String.fromCodePoint()")}} (que forma part de l'esborrant de l'ECMAScript 6) per a retornar el parell de nombres citat i, d'aquesta forma, representar de manera adequada aquests caràcters de valor més alt.

+ +

Especificacions

+ + + + + + + + + + + + + + + + + + + + + + + + +
EspecificacionsEstatComentaris
{{SpecName('ES1')}}{{Spec2('ES1')}}Definició inicial. Implementat a JavaScript 1.2.
{{SpecName('ES5.1', '#sec-15.5.3.2', 'StringfromCharCode')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-string.fromcharcodes', 'String.fromCharCode')}}{{Spec2('ES6')}} 
+ +

Compatibilitat amb navegadors

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
+
+ +

Vegeu també

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