padStart
Commons
stable
Left-pad a string to a target length by prepending 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.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- strrequisstring
- The source string to pad.
- lengthrequisnumber
- The desired minimum total length of the resulting string.
- charstring'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.
Left-pad for fixed-width formatting