Published in

Remove space from string in javascript


Playing with strings in Javascript is a bit tricky. In this article, I am going to describe how to remove space from any string in Javascript.

Even though Javascript provides many inbuilt string functions, we must always aim for using the optimal one to solve any challenge.

Because JavaScript uses the main UI thread and any redundancy can cause a lag in the UI.

Space can be present at any position in a string and, a single solution will not work in every situation.

In this article, I have discussed two ways to:

  1. Remove all extra spacing between words.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store