javascript trim 1

javascript trim

var str = "  Some text ";
str.trim();
// str = "Some text"

Here is what the above code is Doing:
1. We create a string variable called str and assign it the value ” Some text “.
2. We call the trim() method on the str variable.
3. The trim() method removes the whitespace from the beginning and end of the string.
4. The str variable now equals “Some text”.

Similar Posts