trim, padStart, padEnd
Trimming and padding strings.
Examples
Trimming
Removing leading and trailing whitespace.
let text = " Hello World! ";
let result = text.trim();
console.log(result); // "Hello World!"Padding Start
Padding the start of a string until it reaches length 4.
let text = "5";
let padded = text.padStart(4, "0");
console.log(padded); // "0005"Test Your Knowledge
JavaScript Quiz
No quiz available for this topic yet.