Handlebar Helper Function: Length

Returns the number of characters in a specified string or the number of elements in an array.

ParameterTypeDescription
subjectstring or arrayRequired. The string or array to find the length of.

The function returns the number of characters in the input string or the number of elements in the input array. If the input is null, it returns 0.

When measuring strings, the function counts all characters including spaces, punctuation, and special characters. Non-string inputs are converted to strings before counting. The function counts Unicode code units (UTF-16 length), so surrogate pairs count as 2 units.