|
|
|
|
|
by krapp
866 days ago
|
|
It isn't missing. Javascript was created to serve a specific purpose, which didn't include left-padding text in a terminal. Most language I'm aware of wouldn't have that in their standard lib. If you want Javascript to act as a drop-in replacement for C++ or Java or some other general programming language (which Javascript was never intended to be) don't act as if needing to write libraries to cover that missing functionality is a problem with the language. You're using the wrong tool for the wrong job. |
|
Python has str.ljust [1] (and str.rjust [2]):
> Return the string left justified in a string of length width. Padding is done using the specified fillchar (default is an ASCII space). The original string is returned if width is less than or equal to len(s).
[1] https://docs.python.org/3/library/stdtypes.html#str.ljust
[2] https://docs.python.org/3/library/stdtypes.html#str.rjust