cut string space javascript code example
Example 1: javascript remove all whitespaces
var spacesString= "Do I have spaces?";
var noSpacesString= myString.replace(/ /g,'');
Example 2: javascript remove space from string
const removeSpaces = str => str.replace(/\s/g, '');
removeSpaces('hel lo wor ld');
Example 3: how to remove spaces from strings javascript
var str = '/var/www/site/Brand new document.docx';
document.write( str.replace(/\s/g, '') );
Example 4: remove space from string javascript
var puzzle1=myTrim($("#puzzleinput").val());
function myTrim(x) {
return x.replace(/^\s+|\s+$/gm,'');
}