Standard built-ins

String.prototype.padEnd()

Try the free JavaScript compiler

Repeats and truncates filler at the end until the target length is reached; never truncates existing text.

Formal Syntax & Structure

javascript syntaxjavascript
text.padEnd(targetLength, [padString])

Parameters & Attributes

NameTypeDescription
targetLengthNumberDesired code-unit length.
padStringStringFiller, default space.

Return Value

String

Padded text or original value.

Working Example

Example Snippetjavascript
console.log("1".padEnd(3,"0"));
JavaScript Reference