X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

JavaScript String length Property

JavaScript String Reference JavaScript String Reference

Example

Return the number of characters in a string:

var str = "Hello World!";
var n = str.length;

The result of n will be:

12

Try it yourself »


Definition and Usage

The length property returns the length of a string (number of characters).

The length of an empty string is 0.


Browser Support

Property
length  Yes Yes Yes Yes Yes


Syntax

string.length

Technical Details

Return Value: The length of a string
JavaScript Version: 1.0


JavaScript String Reference JavaScript String Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook