suppress spaces in front and in the end of a string javascript

JavaScript
var hello = '     Hello there!    ';

// returns "Hello there!"
hello.trim();

Source

Also in JavaScript: