Skip to content

padEnd

The padEnd() method pads the current string with a given string to obtain a fixed-length string. The padding is applied at the end of the current string.

Interactive example

Syntax

Classic signature

typescript
function padEnd<
	GenericInput extends string
>(
	input: GenericInput,
	targetLength: number,
	padString: string
): string

Curried signature

typescript
function padEnd<
	GenericInput extends string
>(
	targetLength: number,
	padString: string
): (input: GenericInput) => string

Parameters

  • input: The string to pad.
  • targetLength: The length of the resulting string once padded.
  • padString: The string to use to pad the current string.

Return value

A new string of the specified length, padded with the provided string from the end.

See also

  • padStart - Pads the string at the start
  • repeat - Repeats a string a given number of times

Sources

Released under the MIT license.