Truncate String
Truncates a string to a specified length.
Category | Strings |
Author | Pol Gubau |
Since | 1.0.0 |
Last Updated | 2025-03-15 |
Type | Sync |
Compatibility | Universal |
Example
Input
truncateString('This is a long string', 10)
Output:
'This is a...'
Return
Returns the truncated string with an optional suffix.
Type: string
Props
Name | Type | Default | Required | Description |
---|---|---|---|---|
str | string | null | Yes | The string to truncate. |
length | number | 50 | No | The maximum length of the truncated string. |
suffix | string | ... | No | The suffix to append after truncating. |
Notes
This function truncates the string to a specified length, appending a suffix if necessary.
Tags
- string
- truncate