Utilizor
Contact Us

trim, padStart, padEnd

Trimming and padding strings.

String Trim and Padding

trim()

The trim() method removes whitespace from both sides of a string.

Padding

ECMAScript 2017 added two String methods: padStart() and padEnd() to support padding at the beginning and at the end of a string.

Example

let text = "       Hello World!        ";
let result = text.trim();