From da78a9e329e272dedb2400b79a3bdeebff387d47 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:17 -0500 Subject: initial commit --- .../global_objects/string/length/index.html | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 files/it/web/javascript/reference/global_objects/string/length/index.html (limited to 'files/it/web/javascript/reference/global_objects/string/length') diff --git a/files/it/web/javascript/reference/global_objects/string/length/index.html b/files/it/web/javascript/reference/global_objects/string/length/index.html new file mode 100644 index 0000000000..e575b777b8 --- /dev/null +++ b/files/it/web/javascript/reference/global_objects/string/length/index.html @@ -0,0 +1,90 @@ +--- +title: string.length +slug: Web/JavaScript/Reference/Global_Objects/String/length +translation_of: Web/JavaScript/Reference/Global_Objects/String/length +--- +
{{JSRef}}
+ +

La proprietà length di un oggetto {{jsxref("String")}} indica la lunghezza di una stringa, in unità di codice UTF-16.

+ +

Sintassi

+ +
str.length
+ +

Descrizione

+ +

Questa proprietà restituisce il numero di unità di codice nella stringa. {{interwiki("wikipedia", "UTF-16")}}, il formato di stringa utilizzato da JavaScript, utilizza una singola unità di codice a 16 bit per rappresentare i caratteri più comuni, ma deve utilizzare due unità di codice per meno comunemente- caratteri usati, quindi è possibile che il valore restituito dalla length “lunghezza“ non corrisponda al numero effettivo di caratteri nella stringa.

+ +

ECMASCript 2016 (ed. 7) ha stabilito una lunghezza massima di 2^53 - 1 elementi. In precedenza, non è stata specificata una lunghezza massima.. 

+ +

Per una stringa vuota, length è 0.

+ +

La proprietà statica String.length restituisce il valore 1.

+ +

Esempi

+ +

Basic usage

+ +
var x = 'Mozilla';
+var empty = '';
+
+console.log('Mozilla is ' + x.length + ' code units long');
+/* "Mozilla è lungo 7 unità di codice" */
+
+console.log('La stringa vuota ha una lunghezza di
+ ' + empty.length);
+/* "La stringa vuota ha una lunghezza di 0" */
+ +

Assegnazione a length

+ +
var myString = "bluebells";
+
+// Il tentativo di assegnare un valore alla proprietà .length di una stringa non ha alcun effetto osservabile.
+myString.length = 4;
+console.log(myString);
+/* "bluebells" */
+
+ +

Specificazioni

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificazioniStatoCommenti
{{SpecName('ES1')}}{{Spec2('ES1')}}Definizione iniziale Implementato in JavaScript 1.0.
{{SpecName('ES5.1', '#sec-15.5.5.1', 'String.prototype.length')}}{{Spec2('ES5.1')}} 
{{SpecName('ES6', '#sec-properties-of-string-instances-length', 'String.prototype.length')}}{{Spec2('ES6')}} 
{{SpecName('ESDraft', '#sec-properties-of-string-instances-length', 'String.prototype.length')}}{{Spec2('ESDraft')}} 
+ +

Browser compatibili

+ + + +

{{Compat("javascript.builtins.String.length")}}

+ +

Guarda anche

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