Function: pad()
ts
function pad(
value,
length,
fillString?): string;Pads a string on both sides to a target length. 将字符串两侧填充到目标长度。
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
value | string | undefined | The source string / 源字符串 |
length | number | undefined | The target length / 目标长度 |
fillString | string | ' ' | The padding content / 填充内容 |
Returns
string
The padded string / 填充后的字符串
Example
ts
pad('hi', 6)
// => ' hi 'Since
1.2.0