Skip to main content

pad

_.pad(length, string) # Ⓢ [Ⓣ][1] Ⓝ

Pads string on the left and right sides if it's shorter than length.



Padding characters are truncated if they can't be evenly divided by length.

Since​

3.0.0

Arguments​

  1. length (number): The padding length.
  2. string (string): The string to pad.

Returns​

(string): Returns the padded string.

Example​

_.pad(8, 'abc');
// => ' abc '

_.pad([8, '_-'], 'abc');
// => '_-abc_-_'

_.pad(3, 'abc');
// => 'abc'