JavaScript trim method

The trim method of JavaScript is used to remove the leading and trailing spaces in a given string. This may be useful in scenarios where visitors are given options to enter text in textboxes or text area and they enter text with leading or trailing spaces or presenting