Node.js trim() function Last Updated : 30 Mar, 2023 Comments Improve Suggest changes Like Article Like Report 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 accept any parameter. Return Value: The function returns the string without white spaces. The below programs demonstrate the working of trim() function: Program 1: javascript function trim(str) { // Use trim() function let trimContent = str.trim(); console.log(trimContent); } // Initialize variable const str = " *GeeksforGeeks* "; // Function call trim(str); Output: *GeeksforGeeks* Program 2: javascript function trim(str) { // Use trim() function const trimContent = str.trim(); console.log(trimContent); } // Initialize variable const str = " Welcome to GeeksforGeeks "; // Function call trim(str); Output: Welcome to GeeksforGeeks Comment More infoAdvertise with us Next Article Node.js trim() function T Twinkl Bajaj Follow Improve Article Tags : Web Technologies Node.js NodeJS-function Similar Reads Node.js GM trim() Function The trim() function is an inbuilt function in the GraphicsMagick library which is used to remove edges that are exactly the same color as the corner pixels. The function returns the true value of success. Syntax: trim() Parameters: This function does not accept any parameters. Return Value: This f 1 min read Node.js MySQL TRIM() Function TRIM() function is a built-in function in MySQL that is used to trim all spaces from both sides of the input string. Syntax: TRIM(string)Parameters: It takes one parameter as follows: string: It is the string to be trimmed from both sides.Return Value: It returns string after trimming from both side 2 min read Node.js substr() function The substr() function is a string function of Node.js which is used to extract sub-string from the given string. Syntax: string.substr(index, length) Parameters: This function accepts two parameters as mentioned above and described below: index: This parameter holds the starting index of the specifi 1 min read p5.js trim() function The trim() function in p5.js is used to remove whitespace characters and tab from the beginning and end of an input String. This function is also used to remove the carriage return and Unicode "nbsp" character. Syntax: trim(Strings) or trim(Array_of_Strings) Parameters: This function accepts a para 2 min read Node.js slice() function The slice() function is a string function of Node.js which is used to extract sub-string from a string. Syntax: string.slice( start, end ) Parameters: This function uses three parameters as mentioned above and described below: string: It holds the string content. The substring is extracted from this 1 min read Like