In TypeScript, the trim()
method is available on strings to remove whitespace from the beginning and end of a string. Here's an example:
index.ts119 chars5 lines
In the example above, the trim()
method is called on the str
variable, which removes the whitespace from the beginning and end of the string. The resulting string is assigned to the trimmedStr
variable and then logged to the console.
Note that the trim()
method returns a new string and does not modify the original string.
gistlibby LogSnag