Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




trim() - FUNCTION


trim() Function


The trim() Function is used to remove any unwanted character from the String with Space by default.


Example :



<html>
<body>  
<script>

	var x = "   Hello  "
	var y = x.trim()
	document.write(y)
    
</script>      
</body>
</html>


Output :



  Hello

In the above code, we have declared a String Hello with leading and trailing spaces.


var x = "   Hello  "
trim()-Function


Then we have used the trim() function to remove any unwanted spaces from beginning and end.


var y = x.trim()
trim()-Function


Unwanted spaces are stripped out of it.