👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.

js length string

The property string.length returns the number of bytes in a string, i.e. the length.


Example :

str ="Hello world";
len = str.length;  // len = 11, the length of str


Warning : string.length returns the number of bytes, not the number of characters. Some characters (UTF-8, UNICODE ...) are encoded on several bytes :

str ="????";
console.log (str.length); // Display 2

More