JavaScript String method : trim()

The trim() method is used to remove the leading and trailing white-spaces from the string.

Example :
<html>
<body>
  <script>
    var str = "      mycsnotes.com trimed one    ";
    var newStr = str.trim(); 
    document.write(newStr);
  </script> 
</body>
</html>
Output :


Next Topic :