Node.js | trim() function
The trim() function is a string function of Node.js which is used to remove white spaces from the string.
Syntax:
string.trim()
Parameter: This function does not accepts any parameter.
Return Value: The function returns the string without white spaces.
Below programs demonstrate the working of trim() function:
Program 1:
function trim(str) { // Use trim() function var trimContent = str.trim(); console.log(trimContent); } // Initialize variable var str = " *GeeksforGeeks* "; // Function call trim(str); |
chevron_right
filter_none
Output:
*GeeksforGeeks*
Program 2:
function trim(str) { // Use trim() function var trimContent = str.trim(); console.log(trimContent); } // Initialize variable var str = " Welcome to GeeksforGeeks "; // Function call trim(str); |
chevron_right
filter_none
Output:
Welcome to GeeksforGeeks
Recommended Posts:
- Nodejs | Automatic restart NodeJs server with nodemon
- p5.js | trim() function
- PHP | trim() Function
- Nodejs | DNS
- How to trim all strings in an array in PHP ?
- Nodejs | Jimp
- Nodejs | DNS | setServers()
- Web-Socket in NodeJS
- Difference between NodeJS and AngularJS
- Nodejs | Web Crawling using Cheerio
- Dockerizing a simple Nodejs app
- Encrypting Data in NodeJS
- How to trim a file extension from string using JavaScript ?
- NodeJs - Handling invalid routes
- Signup Form Using Nodejs and MongoDB
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



