JavaScript String length property

Definition and usage

length The property returns the length of the string.

The length property of an empty string is 0.

Example

let text = "Hello World!";
let length = text.length;

Try it yourself

Syntax

string.length

Return value

Type Description
Number The length of the string.

Explaination

String.length The property is a read-only property. It declares the length of the specified string string The number of characters in it.

For any string sIts last character index is s.length-1. The fon/in loop cannot enumerate the characters of the length properties, using delete operators cannot delete it.

browser support

length It is an ECMAScript1 (ES1) feature.

All browsers fully support ES1 (JavaScript 1997):

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support

Related Pages

JavaScript String

JavaScript String Methods

JavaScript String Search