Standard built-ins
String.prototype.padStart()
Repeats and truncates filler at the start until the target length is reached; never truncates existing text.
Formal Syntax & Structure
javascript syntaxjavascript
text.padStart(targetLength, [padString])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| targetLength | Number | Desired code-unit length. |
| padString | String | Filler, default space. |
Return Value
String
Padded text or original value.
Working Example
Example Snippetjavascript
console.log("1".padStart(3,"0"));