Skip to content
FLAVIO COPES
flaviocopes.com
2026

The String trim() method

By Flavio Copes

Learn how the JavaScript trim() method returns a new string with the white space removed from the beginning and the end, leaving the original string untouched.

~~~

Return a new string with removed white space from the beginning and the end of the original string

'Testing'.trim() //'Testing'
' Testing'.trim() //'Testing'
' Testing '.trim() //'Testing'
'Testing '.trim() //'Testing'
Tagged: JavaScript ยท All topics
~~~

Related posts about js: