JavaScript: String.prototype.padEnd

By Xah Lee. Date: . Last updated: .

New in JS2017.

str.padEnd(n)
Return a new string, by adding space to the end of string so the length is n.
str.padEnd(n, padstr)
Use padStr to pad.
console.log( "x".padEnd(3) === "x  ");
console.log( "x".padEnd(3, "0") === "x00");
console.log( "x".padEnd(4, "ab") === "xaba");
// true

Note: "😂".length === 2 [see Character, Code Unit, Codepoint]

BUY
ΣJS
JavaScript in Depth

JS Obj Reference

String

prototype