Coy  Roberts

Coy Roberts


Javascript Trim: How to Trim String in Javascript

Javascript string trim() is an inbuilt function that removes whitespace from both sides of the String. Whitespace, in this context, is all of the whitespace characters, including space, tab, no-break space, and all the line terminator characters, including LFCR, etc.

Javascript Trim String

To trim String in JavaScript, use String.trim() method. The trim() method returns the String stripped of whitespaces from both ends of the String. The** trim()** does not affect the value of the String itself.

The trim() function does not take any arguments. For many years, JavaScript has had  String.prototype.trim(), a built-in function to remove both the leading & trailing whitespace.



The trim() does not affect the value of the String itself.

#javascript #javascript trim #string.prototype.trim #js

Javascript Trim: How to Trim String in Javascript