Function length

  • Return the user-perceived character length of the given string, e.g.:

    const test = '๏ฌt๐Ÿš€๐Ÿ‘ซ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ'
    console.log(test.length); // 17
    console.log(length(test)); // 5

    Note, this utility segments the string into grapheme clusters using Intl.Segmenter, a TC39 proposal which reached stage 4 in 2022, and may not be supported in older environments.

    Parameters

    • utf8: string

      the string for which to count the character length.

    Returns number

Generated using TypeDoc