Sometimes, we want to trim spaces from start and end of string with JavaScript.
In this article, we’ll look at how to trim spaces from start and end of string with JavaScript.
How to trim spaces from start and end of string with JavaScript?
To trim spaces from start and end of string with JavaScript, we use the string trim method.
For instance, we write
title = title.trim();
to call title.trim to return a string with the title string’s starting and ending whitespaces trimmed out.
Conclusion
To trim spaces from start and end of string with JavaScript, we use the string trim method.