The trim() method removes whitespace from both ends of a string. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).
var greeting = ' Hello world! I am Prem Tiwari ';
> " Hello world! I am Prem Tiwari "
> "Hello world! I am Prem Tiwari"
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.