Javascript examples for String:trim
The trim() method removes whitespace from both sides of a string.
The trim() method does not change the original string.
None.
A String, representing the string with removed whitespace from both ends
The following code shows how to Remove whitespace from both sides of a string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/*from w w w . ja v a2 s . co m*/ var str = " Hello World! ".trim(); console.log(str); } </script> </body> </html>