JavaScript

How to remove the whitespace from both sides of the string by using JavaScript?

How to remove the whitespace from both sides of the string by using JavaScript?, someone asked me to explain?

In this article we will discuss to remove the whitespace from both sides of the string by using JavaScript. We should use trim() method for removing whitespace.

For example:

<script type="text/javascript">

    var firststring = "infinet ";

    var secondstring = "soft ";

    var result = firststring.trim() + secondstring.trim();

    alert(result);
  </script>


remove whitespace using trim()

Post your comments / questions