ES6 - Proprietà della lunghezza della stringa

Questa proprietà restituisce il numero di caratteri in una stringa.

Sintassi

string.length

Esempio: proprietà del costruttore di stringhe

var uname = new String("Hello World")
console.log(uname)
console.log("Length "+uname.length) // returns the total number of characters // including whitespace

Produzione

Hello World
Length 11