Courses / JavaScript
17. String.prototype.trim()
Removes whitespace from both ends of a string and returns a new string, without modifying the original string.
1 min read Chapter 17 of 99
JavaScript
String.prototype.trim()
The `trim()` method removes whitespace from both ends of a string.
"I often find extra spaces at the start or end of my input strings."
The `trim()` method creates a new string with whitespace removed from the beginning and end of the original string, without altering the original string itself.
"I often find extra spaces at the start or end of my input strings."
The `trim()` method creates a new string with whitespace removed from the beginning and end of the original string, without altering the original string itself.