JavaScript String trim() method : The trim() method is used to trim the unwanted extra space from both sides (left and right). It returns the new string without having the white-space on both sides.
When programming, you may sometimes find "extra spaces" at the beginning or end of a string. Although they are hard to notice visually, these spaces are often the cause of processing errors. The trim ...