remove underscore javascript and space js code example
Example 1: js replace space with underscore
var string = "my name";
string = string.replace(/ /g,"_"); //returns my_name
Example 2: javascript remove all whitespaces
var spacesString= "Do I have spaces?";
var noSpacesString= myString.replace(/ /g,'');// "DoIhavespaces?"