How to get the length of a string

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

String length

length The property returns the length of the string:

Example

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

Try it yourself

Related pages

Tutorial:JavaScript streng

Reference manual:JavaScript length egenskab