.length

The .length string property returns the number of characters in a string.

Syntax

string.length;

Example

Returning the length of a string in number:

console.log('I love New York!'.length);
// Output: 16

Codebyte Example

Edit this page on GitHub

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn JavaScript on Codecademy

Edit this page on GitHub

Contributors