remove all spaces from a string javascript

JavaScript
var spacesString= "Do I have spaces?"; 
var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?".replace(/ /g,'')var str = "       Hello World!        ";
alert(str.trim());
Source

Also in JavaScript: