JavaScript Lunghezza della stringa
Esempio
let text = "Hello World!";
let length = text.length;
Definizione e utilizzo
La length
proprietà restituisce la lunghezza di una stringa.
La length
proprietà di una stringa vuota è 0.
Sintassi
string.length
Valore di ritorno
Tipo | Descrizione |
Un numero | La lunghezza della stringa. |
Supporto browser
length
è una funzione ECMAScript1 (ES1).
ES1 (JavaScript 1997) è completamente supportato in tutti i browser:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |