proposal: String.prototype.padCenter

Ricardo Zorzal ricardozorzal at
Tue Aug 21 23:40:00 UTC 2018

Hello guys, I here to talk about padStart, padEnd and my new proposal "padCenter", I think it is not hard to develop because we already had padStart and padEnd.

I thought that we need to add one more feature to String's prototype, and it is not a hard work. So the proposal is to create the String.prototype.padCenter that centralize a string with a max character lenght, equals we do when call the "pad" functions.

For exemple, when we call padStart

//result: "                         MY-TEST"

and when we call padEnd:

//result: "MY-TEST                         "

how about that:

//result: "            MY-TEST            "

I'm searching it for a long time and I seen people talking about it in different use cases. But for me it will be usefull when I need to send some text data to my bluetooth printer, becouse the length of his line is 32 and I need to centralize the data and adjust the line to right and left.

I think this feature can improve the language and it will be useful for other developers like me.

Although we has libs that has an implementation of it
I think it can be done for native functions too

And it is native for other languages, such as:
    1. PHP (
    2. Python (
    3. Ruby (
    4. R (
    5. etc...

What do you guys think ?

( We can call it "pad" instead of "padCenter"  haha )


Ricardo Zorzal Davila
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list