String.prototype.trim

Returns a string where all whitespace characters have been removed from the beginning and the end.

Syntax

trim()

Return value

A string with leading and trailing whitespace removed.

Examples

"  hello  \n".trim()
"hello"