Open In App

JavaScript String padEnd() Method

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
1 Like
Like
Report

The padEnd() method in JavaScript is used to pad a string with another string until it reaches the given length. The padding is applied from the right end of the string.

Syntax:

string.padEnd( targetLength, padString );

Parameters:

This method accepts two parameters as mentioned above and described below:

  • targetLength: It is the length of the final string once the original string has been padded. If the value is less than the original string length, then the original string is returned.
  • padString: It is the string that is to be padded with the original string. If this value is too long to be within the targetLength, it is truncated.

Return Value:

It returns the final string that is padded with the given string of the given length. 

Example 1: This example uses the padEnd() method to pad strings into another string. 


Output
Hello$$$$$$$
GeeksGeeksGe

Example 2: This example uses the padEnd() method to pad numbers into another number. 


Output
12340000
99******

Supported Browsers:

The browser supported by the padEnd() method are listed below:

  • Google Chrome 3
  • Microsoft Edge 12
  • Mozilla Firefox 3.0
  • Safari 5
  • Opera 10.5

Similar Reads