UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ String/ String.prototype.padEnd()

The padEnd() method of String values pads this string with a given string (repeated, if needed) so that the resulting string reaches a given length. The padding is applied from the end of this string.

Syntax

padEnd(targetLength)
padEnd(targetLength, padString)

Parameters

Return value

A String of the specified targetLength with the padString applied at the end of the current str.

Examples

Using padEnd

"abc".padEnd(10); // "abc       "
"abc".padEnd(10, "foo"); // "abcfoofoof"
"abc".padEnd(6, "123456"); // "abc123"
"abc".padEnd(1); // "abc"

Specifications

Browser compatibility

See also