JavaScript Object Reference
JavaScript: String.prototype.trim
By Xah Lee. Date:
2017-02-17
. Last updated:
2020-09-15
.
str
.trim()
Return a new string with begin/end whitespaces removed. [see
Whitespace Characters
]
console
.
log
(
" ab\n"
.
trim
() ===
"ab"
);
//
true
BUY
ΣJS
JavaScript in Depth
Search 🔍
HTML
CSS
JS
JS Ref
DOM
SVG
JS Obj Reference
String
Constructor
fromCodePoint
fromCharCode
raw
prototype
constructor
length
concat
repeat
trim
trimStart
trimEnd
padStart
padEnd
slice
substring
substr
indexOf
lastIndexOf
includes
startsWith
endsWith
search
match
matchAll
replace
replaceAll
split
toLowerCase
toUpperCase
toLocaleLowerCase
toLocaleUpperCase
charAt
charCodeAt
codePointAt
toString
valueOf
localeCompare
normalize
[Symbol.iterator]