var spacesString= "Do I have spaces?"; var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"
var str = " Some text "; str.trim();
str = str.replace(/\s/g, '');
if (/\s/.test(str)) { // It has any kind of whitespace }
//Removing whitespace from String var str = " Hello World! "; console.log(str.trim());
return str.replace(/\s/g, '');