String.pad_start
String.pad_start
Function
Pad content at the beginning of the string to the target length.
Syntax
string.pad_start(target_len, pad)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| target_len | Number | Yes | None | Target length. |
| pad | String | No | Space | Pad text. |
Return value
| Type | Description |
|---|---|
| String | The new string after filling. |
Code Example
result = '7'.pad_start(3, '0') // Output: 007 print result
Notes
- Return the original string when the current length is greater than or equal to the target length.