JavaScript String length property
- Previous Page lastIndexOf()
- Next Page localeCompare()
- Go Back to the Previous Level JavaScript String Reference Manual
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. |
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 |
- Previous Page lastIndexOf()
- Next Page localeCompare()
- Go Back to the Previous Level JavaScript String Reference Manual