how to get rid of spaces before a string in js code example Example: remove all spaces from a string javascript .replace(/ /g,'')