Removes whitespace from the start and end of a String
without changing the middle.
trim()
trims whitespace characters such as spaces, carriage returns, tabs, Unicode "nbsp" character.
The parameter, str
, is the string to trim. If a single string is passed, as in trim(' pad ')
, a single string is returned. If an array of strings is passed, as in trim([' pad ', '\n space \n'])
, an array of strings is returned.
示例
语法
trim(str)
trim(strs)
参数
str
String:
string to trim.
strs
String[]:
strings to trim.
Returns
String: trimmed string.
Notice any errors or typos? Please let us know. Please feel free to edit src/utilities/string_functions.js and open a pull request!