Date

“String” Methods

_.padStart([string=''], [length=0], [chars=' '])

source npm package

Pads string on the left side if it's shorter than length. Padding characters are truncated if they exceed length.

引入版本

4.0.0

参数
[string=''] (string) : The string to pad.
[length=0] (number) : The padding length.
[chars=' '] (string) : The string used as padding.

返回值
(string) : Returns the padded string.

示例
_.padStart('abc', 6);
// => '   abc'
 
_.padStart('abc', 6, '_-');
// => '_-_abc'
 
_.padStart('abc', 3);
// => 'abc'