padEnd
Commons
stable
Right-pad a string to a target length by appending a repeat of the padding character. If the string is already at or beyond the target length it is returned unchanged.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- strrequiredstring
- The source string to pad.
- lengthrequirednumber
- The desired minimum total length of the resulting string.
- charstring'0'
- The character used for padding. Defaults to `'0'`.
API
Return value
The value returned by this util.
- The padded string. The original string is never mutated.
Usage
Examples
Ready-to-paste usage snippets.
Right-pad with zeros and custom chars