How to Get the Length of a String

Learn how to find the length of a string in JavaScript.

String Length

length The attribute returns the length of the string:

Example

var txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var len = txt.length;

Try It Yourself

Related Pages

Tutorial:JavaScript String

Reference Manual:JavaScript length Attribute