javascrip treplace all spaces code example Example: js replace all spaces var replaced = str.replace(/ /g, '_');