![]() |
VOOZH | about |
The trim() method is used to remove extra spaces from a string. It helps clean user input by removing unwanted whitespace.
str.trim();This method does not accept any parameter.
Returns a new string without any of the leading or trailing white spaces.
[Example 1]: Trimming Whitespace from the End of a String.
[Example 2]: Trimming Leading Whitespace from a String
GeeksforGeeks
[Example 3]: Trimming Whitespace from both sides of String