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.

typescript

API

Parameters

Input parameters accepted by this util.

str
required
string
The source string to pad.
length
required
number
The desired minimum total length of the resulting string.
char
string
'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

typescript