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

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

str
requis
string
The source string to pad.
length
requis
number
The desired minimum total length of the resulting string.
char
string
'0'
The character used for padding. Defaults to `'0'`.

API

Valeur de retour

La valeur retournée par cet util.

The padded string. The original string is never mutated.

Usage

Exemples

Extraits de code prêts à coller.

Right-pad with zeros and custom chars

typescript