trim, padStart, padEndTrimming 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. Examplelet text = " Hello World! "; let result = text.trim();Try it Yourself PreviousNext