# [str.length](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length)
==Returns the length of a string==
___
### Return Value:
`number`
---
The **`length`** property of a [`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) object contains the length of the string, in UTF-16 code units. `length` is a read-only data property of string instances.
## Examples
```js
const str = 'abcde';
str.length //➞ 5
```
## Syntax
```js
```
### Parameters
___
## Description
This property returns the number of code units in the string. UTF-16, the string format used by JavaScript, uses a single 16-bit code unit to represent the most common characters, but needs to use two code units for less commonly-used characters, so it's possible for the value returned by `length` to not match the actual number of characters in the string.
For an empty string, `length` is 0.
The static property `String.length` is unrelated to the length of strings, it's the arity of the `String` function (loosely, the number of formal parameters it has), which is 1
___
## Notes
#### Unicode
Since `length` counts code units instead of characters, if you want to get the number of characters you need something like this:
```js
function getCharacterLength (str) {
// The string iterator that is used here iterates over characters, not mere code units
return [...str].length;
}
getCharacterLength('A\uD87E\uDC04Z'); //➞ 3
```