- The trim() method removes whitespace from both sides of a string.
- The trim() method does not change the original string.
Code:-
- <html>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- <h1>trim()</h1>
- <input type="button" onclick="strfun();" value="Get Answer">
- <script>
- function strfun()
- {
- var str = " space ";
- alert(str.trim()); //remove front and end white space
- }
- </script>
- </body>
- </html>
How to use trim in JavaScript:- Geniusofstudent
Reviewed by Network security
on
July 02, 2019
Rating:
No comments: