JavaScript String trim() method
removes whitespace from both ends of a string

trim() method removes whitespace from the both start and end of a string.

trim() does not accept any parameter.

trim() method returns a new string.

trim() method does not change the original string.

To return a new string with whitespace trimmed from just the start, use trimStart() method.

To return a new string with whitespace trimmed just from the end, use trimEnd() method.

syntax description
remove whitespace from the both ends of myString
myString.trim()