JavaScript String length property
- Föregående sida lastIndexOf()
- Nästa sida localeCompare()
- Åter till föregående nivå JavaScript String referenshandbok
Definition and usage
length
The property returns the length of the string.
The length property of an empty string is 0.
Syntax
string.length
Return value
Type | Description |
---|---|
Number | The length of the string. |
Description
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 sThe last character index of its last character is s.length-1. It is not possible to enumerate the characters of a string using fon/in loops: length
properties, using delete
operators cannot delete it.
browser support
length
It is an ECMAScript1 (ES1) feature.
All web browsers fully support ES1 (JavaScript 1997):
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Stöd | Stöd | Stöd | Stöd | Stöd | Stöd |
- Föregående sida lastIndexOf()
- Nästa sida localeCompare()
- Åter till föregående nivå JavaScript String referenshandbok