It displays the number of array elements or the string character number.
{{ [1, 2, 3, 4]|length }}
Result
4
{{ '1234'|length }}
Result
4
The length filter can have a parameter and it can be included within if tags. In the following example, the length parameter 10 defines that if the number of users is more than 10, the provided message is shown.
{% if users|length > 10 %}
The number of users is more than 10.
{% endif %}