1var spacesString= "Do I have spaces?";
2var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"
1var str=" I have outer spaces ";
2var cleanStr=str.trim();//trim() returns string with outer spaces removed
1var str=" I have outer spaces ";
2var cleanStr=str.trim(); //return:"I have outer spaces" >> outer spaces removed