Javascript remove all spaces from a string

JavaScript provides the replace function, however, unlike other programming languages, does not replace all occurrences of a substring within another string, but only replaces the first occurrence. So if we want to┬áremove all spaces from…