When the padStart method is called, the following steps are taken:
- Let O be ? RequireObjectCoercible(this value).
- Let S be ? ToString(O).
- Let intMaxLength be ? ToLength(maxLength).
- Let stringLength be the number of elements in S.
- If intMaxLength is not greater than stringLength, return S.
- If fillString is undefined, let filler be a string consisting solely of the code unit U+0020 (SPACE).
- Else, let filler be ? ToString(fillString).
- If filler is the empty String, return S.
- Let fillLen be intMaxLength - stringLength.
- Let truncatedStringFiller be a new String value consisting of repeated concatenations of filler truncated to length fillLen.
- Return a new String value computed by the concatenation of truncatedStringFiller and S.
Note: the first argument maxLength will be clamped such that it can be no smaller than the length of the this value. Note: The optional second argument fillString defaults to " " (a string consisting of U+0020 SPACE).
When the padEnd method is called, the following steps are taken:
- Let O be ? RequireObjectCoercible(this value).
- Let S be ? ToString(O).
- Let intMaxLength be ? ToLength(maxLength).
- Let stringLength be the number of elements in S.
- If intMaxLength is not greater than stringLength, return S.
- If fillString is undefined, let filler be a string consisting solely of the code unit U+0020 (SPACE).
- Else, let filler be ? ToString(fillString).
- If filler is the empty String, return S.
- Let fillLen be intMaxLength - stringLength.
- Let truncatedStringFiller be a new String value consisting of repeated concatenations of filler truncated to length fillLen.
- Return a new String value computed by the concatenation of S and truncatedStringFiller.
Note: the first argument maxLength will be clamped such that it can be no smaller than the length of the this value. Note: The optional second argument fillString defaults to " " (a string consisting of U+0020 SPACE).