I am trying to trim the string. I google it for trim.
The tips i am getting.
npm install --save string
var S = require('string');
S('hello ').trim().s; -- this also same issue
Can you any one assist me what is the problem of the above method or anything i have missed it?
The trim() function is a string function of Node. js which is used to remove white spaces from the string. Parameter: This function does not accepts any parameter. Return Value: The function returns the string without white spaces.
Java String trim()The Java String class trim() method eliminates leading and trailing spaces. The Unicode value of space character is '\u0020'. The trim() method in Java string checks this Unicode value before and after the string, if it exists then the method removes the spaces and returns the omitted string.
trim() The trim() method removes whitespace from both ends of a string and returns a new string, without modifying the original string. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.)
You can remove the whitespace in a string by using a string. replace(/\s/g, "") regular expression or a string. split(" "). join("") method.
You don't need jquery for this...
var str = " Hello World! ";
var trimmedStr = str.trim();
console.log(trimmedStr);
This will output the following in the console:
"Hello World!"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With